DigitalPianism_ModulesManager - Version 0.3.0

Version Notes

- Original release

Download this release

Release Info

Developer Digital Pianism
Extension DigitalPianism_ModulesManager
Version 0.3.0
Comparing to
See all releases


Version 0.3.0

Files changed (20) hide show
  1. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Modulesmanager.php +19 -0
  2. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Modulesmanager/Grid.php +130 -0
  3. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/CodePool.php +27 -0
  4. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/ConfigFileExists.php +23 -0
  5. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/DataEntry.php +23 -0
  6. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/DataVersion.php +27 -0
  7. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/FileEnable.php +23 -0
  8. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/FolderPathExists.php +23 -0
  9. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/OutputEnable.php +23 -0
  10. app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/Version.php +23 -0
  11. app/code/community/DigitalPianism/ModulesManager/Helper/Data.php +9 -0
  12. app/code/community/DigitalPianism/ModulesManager/Model/Feed.php +189 -0
  13. app/code/community/DigitalPianism/ModulesManager/Test/Config/Main.php +17 -0
  14. app/code/community/DigitalPianism/ModulesManager/controllers/Adminhtml/ModulesmanagerController.php +49 -0
  15. app/code/community/DigitalPianism/ModulesManager/etc/adminhtml.xml +48 -0
  16. app/code/community/DigitalPianism/ModulesManager/etc/config.xml +47 -0
  17. app/etc/modules/DigitalPianism_ModulesManager.xml +9 -0
  18. package.xml +40 -0
  19. skin/adminhtml/default/default/css/digitalpianism/modulesmanager/styles.css +3 -0
  20. skin/adminhtml/default/default/js/digitalpianism/modulesmanager/script.js +13 -0
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Modulesmanager.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Modulesmanager
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Modulesmanager extends Mage_Adminhtml_Block_Widget_Grid_Container
7
+ {
8
+ /**
9
+ * Constructor
10
+ */
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_modulesmanager';
14
+ $this->_blockGroup = 'modulesmanager';
15
+ $this->_headerText = Mage::helper('modulesmanager')->__('Modules Details');
16
+ parent::__construct();
17
+ $this->_removeButton('add');
18
+ }
19
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Modulesmanager/Grid.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Modulesmanager_Grid
5
+ * This is the block representing the grid of reports
6
+ */
7
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Modulesmanager_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ /**
10
+ * Constructor the grid
11
+ */
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('modulesmanagerGrid');
16
+ $this->setDefaultSort('code_pool','DESC');
17
+ $this->setSaveParametersInSession(true);
18
+ }
19
+
20
+ /**
21
+ * Prepare the collection to display in the grid
22
+ */
23
+ protected function _prepareCollection()
24
+ {
25
+ // Create a collection
26
+ $collection = Mage::getSingleton('modulesmanager/feed');
27
+
28
+ // We set the collection of the grid
29
+ $this->setCollection($collection);
30
+ return parent::_prepareCollection();
31
+ }
32
+
33
+ /**
34
+ * Prepare the columns of the grid
35
+ */
36
+ protected function _prepareColumns()
37
+ {
38
+ $this->addColumn('name', array(
39
+ 'header' => Mage::helper('modulesmanager')->__('Name'),
40
+ 'index' => 'name'
41
+ ));
42
+
43
+ $this->addColumn('file_enable', array(
44
+ 'header' => Mage::helper('modulesmanager')->__('Active'),
45
+ 'index' => 'file_enable',
46
+ 'type' => 'options',
47
+ 'options' => array(
48
+ "true" => Mage::helper('modulesmanager')->__('Yes'),
49
+ "false" => Mage::helper('modulesmanager')->__('No')
50
+ ),
51
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_fileEnable'
52
+ ));
53
+
54
+ $this->addColumn('code_pool', array(
55
+ 'header' => Mage::helper('modulesmanager')->__('Code Pool'),
56
+ 'index' => 'code_pool',
57
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_codePool'
58
+ ));
59
+
60
+ $this->addColumn('version', array(
61
+ 'header' => Mage::helper('modulesmanager')->__('Version'),
62
+ 'index' => 'version',
63
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_version'
64
+ ));
65
+
66
+ $this->addColumn('folder_path', array(
67
+ 'header' => Mage::helper('modulesmanager')->__('Folder Path'),
68
+ 'index' => 'folder_path',
69
+ ));
70
+
71
+ $this->addColumn('folder_path_exists', array(
72
+ 'header' => Mage::helper('modulesmanager')->__('Folder Path Exists'),
73
+ 'index' => 'folder_path_exists',
74
+ 'type' => 'options',
75
+ 'options' => array(
76
+ "true" => Mage::helper('modulesmanager')->__('Yes'),
77
+ "false" => Mage::helper('modulesmanager')->__('No')
78
+ ),
79
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_folderPathExists'
80
+ ));
81
+
82
+ $this->addColumn('data_entry', array(
83
+ 'header' => Mage::helper('modulesmanager')->__('Data Entry'),
84
+ 'index' => 'data_entry',
85
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_dataEntry'
86
+ ));
87
+
88
+ $this->addColumn('data_version', array(
89
+ 'header' => Mage::helper('modulesmanager')->__('Data Version'),
90
+ 'index' => 'data_version',
91
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_dataVersion'
92
+ ));
93
+
94
+ $this->addColumn('output_enable', array(
95
+ 'header' => Mage::helper('modulesmanager')->__('Output Enable'),
96
+ 'index' => 'output_enable',
97
+ 'type' => 'options',
98
+ 'options' => array(
99
+ "true" => Mage::helper('modulesmanager')->__('Yes'),
100
+ "false" => Mage::helper('modulesmanager')->__('No')
101
+ ),
102
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_outputEnable'
103
+ ));
104
+
105
+ $this->addColumn('config_file_path', array(
106
+ 'header' => Mage::helper('modulesmanager')->__('Config File Path'),
107
+ 'index' => 'config_file_path'
108
+ ));
109
+
110
+ $this->addColumn('config_file_exists', array(
111
+ 'header' => Mage::helper('modulesmanager')->__('Config File Exists ?'),
112
+ 'index' => 'config_file_exists',
113
+ 'type' => 'options',
114
+ 'options' => array(
115
+ "true" => Mage::helper('modulesmanager')->__('Yes'),
116
+ "false" => Mage::helper('modulesmanager')->__('No')
117
+ ),
118
+ 'renderer' => 'modulesmanager/adminhtml_template_grid_renderer_configFileExists'
119
+ ));
120
+
121
+ return $this;
122
+ }
123
+
124
+ protected function _prepareLayout()
125
+ {
126
+ $this->getLayout()->getBlock('head')->addItem('skin_css','css/digitalpianism/modulesmanager/styles.css');
127
+ $this->getLayout()->getBlock('head')->addItem('skin_js','js/digitalpianism/modulesmanager/script.js');
128
+ return parent::_prepareLayout();
129
+ }
130
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/CodePool.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_CodePool
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_CodePool extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $codePool = $row->getCodePool();
17
+ if ($codePool == "undefined")
18
+ {
19
+ return Mage::helper('modulesmanager')->__("This module is defined within xml files under the app/etc/modules folder but is not configured properly. They may be defined under not properly named file or different module name files.");
20
+ }
21
+ else if (!$codePool)
22
+ {
23
+ return "<p class='error'>".Mage::helper('modulesmanager')->__("Undefined")."</p>";
24
+ }
25
+ else return $codePool;
26
+ }
27
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/ConfigFileExists.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_ConfigFileExists
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_ConfigFileExists extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $fileExists = $row->getConfigFileExists();
17
+ if ($fileExists == "false")
18
+ {
19
+ return "<p class='error'>".Mage::helper('modulesmanager')->__('%s does not exist',$row->getConfigFilePath())."</p>";
20
+ }
21
+ else return "<p class='pass'>".$fileExists."</p>";
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/DataEntry.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_DataEntry
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_DataEntry extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $dataEntry = $row->getDataEntry();
17
+ if (!$dataEntry)
18
+ {
19
+ return "<p class='notapplicable'>".$dataEntry."</p>";
20
+ }
21
+ else return $dataEntry;
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/DataVersion.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_DataVersion
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_DataVersion extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $dataVersion = $row->getDataVersion();
17
+ if ($dataVersion != $row->getVersion() && $row->getDataEntry())
18
+ {
19
+ return "<p class='error'>".$dataVersion."</p>";
20
+ }
21
+ elseif (!$dataVersion)
22
+ {
23
+ return "<p class='notapplicable'>".$dataVersion."</p>";
24
+ }
25
+ else return $dataVersion;
26
+ }
27
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/FileEnable.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_FileEnable
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_FileEnable extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $fileEnable = $row->getFileEnable();
17
+ if ($fileEnable == "true")
18
+ {
19
+ return "<p class='pass'>".$fileEnable."</p>";
20
+ }
21
+ else return "<p class='error'>".$fileEnable."</p>";
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/FolderPathExists.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_FolderPathExists
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_FolderPathExists extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $pathExists = $row->getFolderPathExists();
17
+ if ($pathExists == "false")
18
+ {
19
+ return "<p class='error'>".Mage::helper('modulesmanager')->__('%s does not exist',$row->getFolderPath())."</p>";
20
+ }
21
+ else return "<p class='pass'>".$pathExists."</p>";
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/OutputEnable.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_OutputEnable
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_OutputEnable extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $outputEnable = $row->getOutputEnable();
17
+ if ($outputEnable == "true")
18
+ {
19
+ return "<p class='pass'>".$outputEnable."</p>";
20
+ }
21
+ else return "<p class='error'>".$outputEnable."</p>";
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Block/Adminhtml/Template/Grid/Renderer/Version.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_Version
5
+ */
6
+ class DigitalPianism_ModulesManager_Block_Adminhtml_Template_Grid_Renderer_Version extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
7
+ {
8
+ /**
9
+ * Renders grid column
10
+ *
11
+ * @param Varien_Object $row
12
+ * @return string
13
+ */
14
+ public function render(Varien_Object $row)
15
+ {
16
+ $version = $row->getVersion();
17
+ if ($version != $row->getDataVersion() && $row->getDataEntry())
18
+ {
19
+ return "<p class='error'>".$version."</p>";
20
+ }
21
+ else return $version;
22
+ }
23
+ }
app/code/community/DigitalPianism/ModulesManager/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Helper_Data
5
+ */
6
+ class DigitalPianism_ModulesManager_Helper_Data extends Mage_Core_Helper_Abstract
7
+ {
8
+
9
+ }
app/code/community/DigitalPianism/ModulesManager/Model/Feed.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class DigitalPianism_ModulesManager_Model_Feed extends Varien_Data_Collection
4
+ {
5
+ public function load($printQuery = false, $logQuery = false)
6
+ {
7
+ // Skip if already loaded
8
+ if ($this->isLoaded()) {
9
+ return $this;
10
+ }
11
+
12
+ if (empty($this->_items)) {
13
+ // Get the config
14
+ $config = Mage::getConfig();
15
+
16
+ // Loop through the modules
17
+ foreach ($config->getNode('modules')->children() as $module) {
18
+ // Create an object
19
+ $item = new Varien_Object;
20
+
21
+ // Module name
22
+ $item->setName($module->getName());
23
+
24
+ // Module Active
25
+ $item->setFileEnable((string)$module->active);
26
+
27
+ // Module Code Pool
28
+ $item->setCodePool((string)$module->codePool);
29
+
30
+ // Module Version
31
+ $version = Mage::getConfig()->getModuleConfig($module->getName())->version ? Mage::getConfig()->getModuleConfig($module->getName())->version : "undefined";
32
+ $item->setVersion($version);
33
+
34
+ // Folder Path
35
+ $dir = $config->getOptions()->getCodeDir().DS.$module->codePool.DS.uc_words($module->getName(),DS);
36
+ $item->setFolderPath($dir);
37
+
38
+ // Folder Exists
39
+ $pathExists = (file_exists($dir) ? "true" : "false");
40
+ $item->setFolderPathExists($pathExists);
41
+
42
+ // Config File Exists
43
+ $file = $config->getModuleDir('etc', $module->getName()).DS."config.xml";
44
+ $item->setConfigFilePath($file);
45
+
46
+ $exists = file_exists($file);
47
+
48
+ if ($exists)
49
+ {
50
+ // Get the config.xml file
51
+ $configXml = simplexml_load_string(file_get_contents($file),'Varien_Simplexml_Element');
52
+ // Get the resources tag
53
+ if ($nodes = $configXml->global->resources)
54
+ {
55
+ // Reset the pointer to the beginning of the array
56
+ reset($nodes);
57
+ // Get the resource name (first key in the array)
58
+ $resourceName = key($nodes);
59
+ }
60
+ else
61
+ {
62
+ $resourceName = '';
63
+ }
64
+
65
+ $item->setDataEntry($resourceName);
66
+
67
+ if (!$resourceName) $dataVersion = '';
68
+ else
69
+ {
70
+ // Get the data version based on the resource name
71
+ $dataVersion = Mage::getResourceSingleton('core/resource')->getDataVersion($resourceName);
72
+ }
73
+
74
+ $item->setDataVersion($dataVersion);
75
+
76
+ // Please note that the 0 value means Enabled and 1 means Disabled
77
+ $disableOutput = Mage::getStoreConfig('advanced/modules_disable_output/'.$module->getName()) ? 'false' : 'true';
78
+
79
+ $item->setOutputEnable($disableOutput);
80
+ }
81
+ else
82
+ {
83
+ $item->setDataEntry('');
84
+ $item->setDataVersion('');
85
+ $item->setOutputEnable('');
86
+ }
87
+
88
+ $exists = $exists ? 'true' : 'false';
89
+ $item->setConfigFileExists($exists);
90
+
91
+ $this->addItem($item);
92
+ }
93
+ }
94
+ $this->_setIsLoaded();
95
+ $this->_renderFilters()->_renderOrders()->_renderLimit();
96
+ return $this;
97
+ }
98
+
99
+ // This function is called by Magento when you type a text on a search field in a grid
100
+ // $field : field we want to filter
101
+ // $condition : Array ( [like] => Zend_Db_Expr Object ( [_expression:protected] => '%USER STRING%' ) )
102
+ // It's the most classical type of condition, a string with a LIKE search like SQL, you can modify and
103
+ // complete the code to implements other filters, if you do this, tell me on comments!
104
+ public function addFieldToFilter($field, $condition = null)
105
+ {
106
+ $keyFilter = key($condition);
107
+ $valueFilter = $condition[$keyFilter]->__toString();
108
+ $this->addFilter($field,$valueFilter,'and');
109
+ return $this;
110
+ }
111
+
112
+ protected function _renderFilters()
113
+ {
114
+ // If elements are already filtered, return this
115
+ if ($this->_isFiltersRendered) {
116
+ return $this;
117
+ }
118
+
119
+ foreach($this->_filters AS $filter){
120
+ $keyFilter = $filter->getData()['field'];
121
+ $valueFilter = substr($filter->getData()['value'],2,-2); // Delete '% AND %' of the string
122
+ $condFilter = $filter->getData()['type']; // not used in this example
123
+
124
+ // Loop you're item collection
125
+ foreach($this->_items AS $key => $item){
126
+
127
+ // If it's not an array, we use the search term to compare with the value of our item
128
+ if(!is_array($item->{$keyFilter})){
129
+ if(!(strpos(strtolower($item->{$keyFilter}),strtolower($valueFilter)) !== FALSE)){
130
+ unset($this->_items[$key]);
131
+ // If search term not founded, unset the item to not display it!
132
+ }
133
+ } else {
134
+ // If it's an array
135
+ $founded = false;
136
+ foreach($item->{$keyFilter} AS $valeur){
137
+ if(strpos(strtolower($valeur),strtolower($valueFilter)) !== FALSE){
138
+ $founded = true;
139
+ }
140
+ }
141
+ if(!$founded)
142
+ unset($this->_items[$key]); // Not founded in the array, so unset the item
143
+ }
144
+ }
145
+
146
+ }
147
+
148
+ $this->_isFiltersRendered = true;
149
+ return $this;
150
+ }
151
+
152
+ protected function _renderOrders()
153
+ {
154
+ $keySort = key($this->_orders);
155
+ $keyDirection = $this->_orders[$keySort];
156
+ // We sort our items tab with a custom function AT THE BOTTOM OF THIS CODE
157
+ usort($this->_items, $this->_build_sorter($keySort,$keyDirection));
158
+ return $this;
159
+ }
160
+
161
+ protected function _renderLimit()
162
+ {
163
+ if ($this->_pageSize) {
164
+ $currentPage = $this->getCurPage();
165
+ $pageSize = $this->_pageSize;
166
+ $firstItem = (($currentPage - 1) * $pageSize + 1);
167
+ $lastItem = $firstItem + $pageSize;
168
+ $iterator = 1;
169
+ foreach ($this->getItems() as $key => $item) {
170
+ $pos = $iterator;
171
+ $iterator++;
172
+ if ($pos >= $firstItem && $pos <= $lastItem) {
173
+ continue;
174
+ }
175
+ $this->removeItemByKey($key);
176
+ }
177
+ }
178
+ return $this;
179
+ }
180
+
181
+ protected function _build_sorter($key,$direction) {
182
+ return function ($a, $b) use ($key,$direction) {
183
+ if ($direction == self::SORT_ORDER_ASC)
184
+ return strnatcmp($a[$key], $b[$key]); // Natural comparaison of string
185
+ else
186
+ return -1 * strnatcmp($a[$key], $b[$key]); // reverse the result if sort order desc !
187
+ };
188
+ }
189
+ }
app/code/community/DigitalPianism/ModulesManager/Test/Config/Main.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: Raph
5
+ * Date: 28/11/2014
6
+ * Time: 11:10
7
+ */
8
+
9
+ class DigitalPianism_ModulesManager_Test_Config_Main extends EcomDev_PHPUnit_Test_Case_Config
10
+ {
11
+ public function testModuleVersion()
12
+ {
13
+ // Testing configuration
14
+ $this->assertModuleCodePool('local');
15
+ $this->assertModuleVersion("0.3.0");
16
+ }
17
+ }
app/code/community/DigitalPianism/ModulesManager/controllers/Adminhtml/ModulesmanagerController.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class DigitalPianism_ModulesManager_Adminhtml_ModulesmanagerController
5
+ */
6
+ class DigitalPianism_ModulesManager_Adminhtml_ModulesmanagerController extends Mage_Adminhtml_Controller_Action
7
+ {
8
+
9
+ /**
10
+ * Check the ACL permission
11
+ * @return mixed
12
+ */
13
+ protected function _isAllowed()
14
+ {
15
+ return Mage::getSingleton('admin/session')->isAllowed('system/tools/modulesmanager');
16
+ }
17
+
18
+ /**
19
+ * This is the action used to display the grid
20
+ */
21
+ public function indexAction()
22
+ {
23
+ $this->_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Modules Details'));
24
+
25
+ if($this->getRequest()->getParam('ajax')) {
26
+ $this->_forward('grid');
27
+ return;
28
+ }
29
+
30
+ $this->loadLayout();
31
+ $this->_setActiveMenu('system');
32
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'));
33
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Tools'), Mage::helper('adminhtml')->__('Tools'));
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Reports Viewer'), Mage::helper('adminhtml')->__('Modules Details'));
35
+
36
+ $this->_addContent($this->getLayout()->createBlock('modulesmanager/adminhtml_modulesmanager', 'modulesmanager'));
37
+
38
+ $this->renderLayout();
39
+ }
40
+
41
+ /**
42
+ * Report list action
43
+ */
44
+ public function gridAction()
45
+ {
46
+ $this->getResponse()->setBody($this->getLayout()->createBlock('modulesmanager/adminhtml_modulesmanager_grid')->toHtml());
47
+ }
48
+
49
+ }
app/code/community/DigitalPianism/ModulesManager/etc/adminhtml.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <menu>
4
+ <!-- System Menu -->
5
+ <system>
6
+ <children>
7
+ <!-- Tools Item -->
8
+ <tools>
9
+ <children>
10
+ <!-- Submenu -->
11
+ <modulesmanager translate="title" module="modulesmanager">
12
+ <title>Modules Details</title>
13
+ <sort_order>10</sort_order>
14
+ <action>adminhtml/modulesmanager/index</action>
15
+ </modulesmanager>
16
+ </children>
17
+ </tools>
18
+ </children>
19
+ </system>
20
+ </menu>
21
+
22
+ <acl>
23
+ <resources>
24
+ <all>
25
+ <title>Allow Everything</title>
26
+ </all>
27
+ <admin>
28
+ <children>
29
+ <!-- System Menu -->
30
+ <system>
31
+ <children>
32
+ <!-- Tools item -->
33
+ <tools>
34
+ <children>
35
+ <!-- Submenu -->
36
+ <modulesmanager>
37
+ <title>Modules Details</title>
38
+ <sort_order>20</sort_order>
39
+ </modulesmanager>
40
+ </children>
41
+ </tools>
42
+ </children>
43
+ </system>
44
+ </children>
45
+ </admin>
46
+ </resources>
47
+ </acl>
48
+ </config>
app/code/community/DigitalPianism/ModulesManager/etc/config.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DigitalPianism_ModulesManager>
5
+ <version>0.3.0</version>
6
+ </DigitalPianism_ModulesManager>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <adminhtml>
11
+ <args>
12
+ <modules>
13
+ <DigitalPianism_ModulesManager before="Mage_Adminhtml">DigitalPianism_ModulesManager_Adminhtml</DigitalPianism_ModulesManager>
14
+ </modules>
15
+ </args>
16
+ </adminhtml>
17
+ </routers>
18
+ </admin>
19
+ <global>
20
+ <models>
21
+ <!-- Model declaration -->
22
+ <modulesmanager>
23
+ <class>DigitalPianism_ModulesManager_Model</class>
24
+ </modulesmanager>
25
+ </models>
26
+ <helpers>
27
+ <!-- Helper declaration -->
28
+ <modulesmanager>
29
+ <class>DigitalPianism_ModulesManager_Helper</class>
30
+ </modulesmanager>
31
+ </helpers>
32
+ <blocks>
33
+ <!-- Block declaration -->
34
+ <modulesmanager>
35
+ <class>DigitalPianism_ModulesManager_Block</class>
36
+ </modulesmanager>
37
+ </blocks>
38
+
39
+ </global>
40
+ <phpunit>
41
+ <suite>
42
+ <modules>
43
+ <DigitalPianism_ModulesManager/>
44
+ </modules>
45
+ </suite>
46
+ </phpunit>
47
+ </config>
app/etc/modules/DigitalPianism_ModulesManager.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DigitalPianism_ModulesManager>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </DigitalPianism_ModulesManager>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DigitalPianism_ModulesManager</name>
4
+ <version>0.3.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module will let you access details about the modules installed on your Magento store.</summary>
10
+ <description>&lt;h2&gt;Description&lt;/h2&gt;&#xD;
11
+ &lt;p&gt;This module is based on &lt;a href="http://alanstorm.com/magento_list_module"&gt;Alan Storm's Module List module&lt;/a&gt;. The main difference is that it adds an extra more information about the modules to help people debugging their modules. It also uses a grid that could help for filtering/searching modules.&lt;/p&gt;&#xD;
12
+ &#xD;
13
+ &lt;h2&gt;Modules Manager&lt;/h2&gt;&#xD;
14
+ &#xD;
15
+ &lt;p&gt;You can access the grid by clicking System &gt; Tools &gt; Modules Details. In this grid, you can find the following information about modules:&lt;/p&gt;&#xD;
16
+ &#xD;
17
+ &lt;ul&gt;&#xD;
18
+ &lt;li&gt;Name of the module&lt;/li&gt;&#xD;
19
+ &lt;li&gt;Active: based on the app/etc/modules configuration file.&lt;/li&gt;&#xD;
20
+ &lt;li&gt;Code Pool&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Version: this is the version of the module as declared in the etc/config.xml file&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Folder path to the module files&lt;/li&gt;&#xD;
23
+ &lt;li&gt;Whether or not the folder path exists&lt;/li&gt;&#xD;
24
+ &lt;li&gt;Data entry: if the module interacts with the database, this will list the entry of the module under the core_resource table&lt;/li&gt;&#xD;
25
+ &lt;li&gt;Data version: this is the data version of your module, understand the data installed via data install/upgrade scripts&lt;/li&gt;&#xD;
26
+ &lt;li&gt;Output enable: wheter or not the output is disabled under System &gt; Configuration &gt; Advanced&lt;/li&gt;&#xD;
27
+ &lt;li&gt;Path to the config file&lt;/li&gt;&#xD;
28
+ &lt;li&gt;Whether or not the config file exists&lt;/li&gt;&#xD;
29
+ &lt;/ul&gt;&#xD;
30
+ &#xD;
31
+ &lt;p&gt;This grid should give you a quick overview of your modules and help you finding out problems while installing/developping a module&lt;/p&gt;&#xD;
32
+ &lt;p&gt;In addition, you can also use our &lt;a href="http://www.digital-pianism.com/en/magento-modules/error-reports-viewer.html"&gt;Reports Viewer&lt;/a&gt; module to view the Magento generated reports easily&lt;/p&gt;</description>
33
+ <notes>- Original release</notes>
34
+ <authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
35
+ <date>2016-01-06</date>
36
+ <time>16:53:23</time>
37
+ <contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="ModulesManager"><dir name="Block"><dir name="Adminhtml"><dir name="Modulesmanager"><file name="Grid.php" hash="93a05492d6cd807198ea76f7850d46f7"/></dir><file name="Modulesmanager.php" hash="dab1b9fde93f930173ddb52c21b6e27f"/><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="CodePool.php" hash="0a7f2f1a16e779560b46e833283bf316"/><file name="ConfigFileExists.php" hash="df2c23b3866a4e55d4554d0c73a1a65a"/><file name="DataEntry.php" hash="627d053695f48360059e59401aee82c9"/><file name="DataVersion.php" hash="bff0b6dcca7eaeba55957bb1bd11e380"/><file name="FileEnable.php" hash="92ae35f0c2bb881f6b4dafde6cbdef5f"/><file name="FolderPathExists.php" hash="13aa662efaabc4826f50412ab0f8ad6d"/><file name="OutputEnable.php" hash="b943b598fabbcff3a2fdc97a2e295e62"/><file name="Version.php" hash="2d50ca4e69a72e18e0a29603aed9fb55"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8a75a26b67acf4307d64c9a8def68dc7"/></dir><dir name="Model"><file name="Feed.php" hash="6109967c56e7a9a5218231a3b8b865e1"/></dir><dir name="Test"><dir name="Config"><file name="Main.php" hash="4d34af1730d7bcd25cd20672efd031fe"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ModulesmanagerController.php" hash="fb029a68dd7a0dfa08362eb337c99342"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6ff14bc193f36129608a84de7a2db6d6"/><file name="config.xml" hash="fd2594038fda51a7bc8693af988493c7"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_ModulesManager.xml" hash="c9498ee1ce38bfc03c45ff585243c5fb"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><dir name="digitalpianism"><dir name="modulesmanager"><file name="styles.css" hash="0c96f305e8cfc02281436d83d54f4aa6"/></dir></dir></dir><dir name="js"><dir name="digitalpianism"><dir name="modulesmanager"><file name="script.js" hash="e753856406dccef91d14c74052089183"/></dir></dir></dir></dir></dir></dir></target></contents>
38
+ <compatible/>
39
+ <dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
40
+ </package>
skin/adminhtml/default/default/css/digitalpianism/modulesmanager/styles.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .error {background-color:red;color:white !important;}
2
+ .pass{background-color:green;}
3
+ .notapplicable{background-color:grey}
skin/adminhtml/default/default/js/digitalpianism/modulesmanager/script.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Event.observe(window, 'load', function() {
2
+ $$('p.error').each(function(elem){
3
+ elem.up().addClassName('error');
4
+ });
5
+
6
+ $$('p.pass').each(function(elem){
7
+ elem.up().addClassName('pass');
8
+ });
9
+
10
+ $$('p.notapplicable').each(function(elem){
11
+ elem.up().addClassName('notapplicable');
12
+ });
13
+ });