modules_conflict_detector - Version 0.1.0.0

Version Notes

Check if you don't have any conflicts in rewrites between installed modules.

Download this release

Release Info

Developer Marcin Frymark
Extension modules_conflict_detector
Version 0.1.0.0
Comparing to
See all releases


Version 0.1.0.0

Files changed (20) hide show
  1. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Explanations.php +30 -0
  2. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites.php +20 -0
  3. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid.php +70 -0
  4. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid/Renderer/DetailsButton.php +21 -0
  5. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid/Renderer/Rewrites.php +25 -0
  6. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/System/Config/Form/Field/AlekseonLogo.php +16 -0
  7. app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/System/Config/Form/Field/AlekseonNotification.php +16 -0
  8. app/code/community/Alekseon/ModulesConflictDetector/Helper/Data.php +14 -0
  9. app/code/community/Alekseon/ModulesConflictDetector/Model/AlekseonAdminNotification/Feed.php +95 -0
  10. app/code/community/Alekseon/ModulesConflictDetector/Model/AlekseonAdminNotification/Observer.php +18 -0
  11. app/code/community/Alekseon/ModulesConflictDetector/Model/Resource/Collection.php +10 -0
  12. app/code/community/Alekseon/ModulesConflictDetector/Model/Resource/NonDbCollection.php +139 -0
  13. app/code/community/Alekseon/ModulesConflictDetector/Model/Rewrites.php +184 -0
  14. app/code/community/Alekseon/ModulesConflictDetector/controllers/Adminhtml/ModulesConflictDetectorController.php +34 -0
  15. app/code/community/Alekseon/ModulesConflictDetector/etc/adminhtml.xml +58 -0
  16. app/code/community/Alekseon/ModulesConflictDetector/etc/config.xml +64 -0
  17. app/code/community/Alekseon/ModulesConflictDetector/etc/system.xml +74 -0
  18. app/design/adminhtml/default/default/template/alekseon/modulesConflictDetector/explanations.phtml +9 -0
  19. app/etc/modules/Alekseon_ModulesConflictDetector.xml +17 -0
  20. package.xml +18 -0
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Explanations.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_Explanations extends Mage_Adminhtml_Block_Template
9
+ {
10
+ protected function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->setTemplate('alekseon/modulesConflictDetector/explanations.phtml');
14
+ }
15
+
16
+ public function getConflictColor()
17
+ {
18
+ return Alekseon_ModulesConflictDetector_Model_Rewrites::CONFLICT_COLOR;
19
+ }
20
+
21
+ public function getNoConflictColor()
22
+ {
23
+ return Alekseon_ModulesConflictDetector_Model_Rewrites::NO_CONFLICT_COLOR;
24
+ }
25
+
26
+ public function getConflictResolvedColor()
27
+ {
28
+ return Alekseon_ModulesConflictDetector_Model_Rewrites::RESOLVED_CONFLICT_COLOR;
29
+ }
30
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_Rewrites extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+
11
+ public function __construct()
12
+ {
13
+ $this->_blockGroup = 'alekseon_modulesConflictDetector';
14
+ $this->_controller = 'adminhtml_rewrites';
15
+ $this->_headerText = Mage::helper('alekseon_modulesConflictDetector')->__('Modules Conflict Detector');
16
+ parent::__construct();
17
+ $this->removeButton('add');
18
+ }
19
+
20
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_Rewrites_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('modules_rewrites_grid');
15
+ $this->setSaveParametersInSession(true);
16
+ $this->setDefaultSort('conflict');
17
+ $this->setDefaultDir('asc');
18
+ $this->setUseAjax(true);
19
+ $this->setPagerVisibility(false);
20
+ }
21
+
22
+ protected function _prepareColumns()
23
+ {
24
+
25
+ $this->addColumn('class',
26
+ array(
27
+ 'header' => Mage::helper('alekseon_modulesConflictDetector')->__('Initial Class'),
28
+ 'index' => 'class',
29
+ ));
30
+
31
+ $this->addColumn('type',
32
+ array(
33
+ 'header' => Mage::helper('alekseon_modulesConflictDetector')->__('Type'),
34
+ 'index' => 'type',
35
+ 'type' => 'options',
36
+ 'options' => Mage::getSingleton('alekseon_modulesConflictDetector/rewrites')->getTypes(),
37
+ ));
38
+
39
+ $this->addColumn('rewrites',
40
+ array(
41
+ 'header' => Mage::helper('alekseon_modulesConflictDetector')->__('Rewrites'),
42
+ 'index' => 'rewrites',
43
+ 'renderer'=> 'alekseon_modulesConflictDetector/adminhtml_rewrites_grid_renderer_rewrites',
44
+ ));
45
+
46
+ $this->addColumn('conflict',
47
+ array(
48
+ 'header' => Mage::helper('alekseon_modulesConflictDetector')->__('Conflict'),
49
+ 'index' => 'conflict',
50
+ 'type' => 'options',
51
+ 'options' => Mage::getSingleton('alekseon_modulesConflictDetector/rewrites')->getConflictTypes(),
52
+ ));
53
+
54
+ return parent::_prepareColumns();
55
+ }
56
+
57
+ protected function _prepareCollection()
58
+ {
59
+ $collection = Mage::getModel('alekseon_modulesConflictDetector/rewrites')->getRewritesCollection();
60
+ $this->setCollection($collection);
61
+
62
+ return parent::_prepareCollection();
63
+ }
64
+
65
+ public function getRowUrl($item)
66
+ {
67
+ return false;
68
+ }
69
+
70
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid/Renderer/DetailsButton.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_Rewrites_Grid_Renderer_DetailsButton extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
+ {
10
+ public function render(Varien_Object $row)
11
+ {
12
+ $url = $this->getGridUrl($row->getClass());
13
+ $label = Mage::helper('alekseon_modulesConflictDetector')->__('Show Details');
14
+ return '<a href="' . $url . '">' . $label . '</a>';
15
+ }
16
+
17
+ public function getGridUrl($class = null)
18
+ {
19
+ return $this->getUrl('*/*/details', array('class' => $class));
20
+ }
21
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/Rewrites/Grid/Renderer/Rewrites.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_Rewrites_Grid_Renderer_Rewrites extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
9
+ {
10
+ public function render(Varien_Object $row)
11
+ {
12
+ $rewrites = $row->getRewrites();
13
+ $result = array();
14
+
15
+ foreach($rewrites['classes'] as $rewrite) {
16
+ if (isset($rewrite['color'])) {
17
+ $result[] = '<span style="color:' . $rewrite['color'] . ';">' . $rewrite['class'] . '</span>';
18
+ } else {
19
+ $result[] = $rewrite['class'];
20
+ }
21
+ }
22
+
23
+ return implode('<br/>', $result);
24
+ }
25
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/System/Config/Form/Field/AlekseonLogo.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_System_Config_Form_Field_AlekseonLogo extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
9
+ {
10
+ public function render(Varien_Data_Form_Element_Abstract $element)
11
+ {
12
+ $alekseonUrl = Mage::helper('alekseon_modulesConflictDetector')->getAlekseonUrl();
13
+ $createdAtImageUrl = $alekseonUrl . '/images/created_by_alekseon.png';
14
+ return '<div><a href="' . $alekseonUrl . '" target="_blank"><img src="' . $createdAtImageUrl . '" alt="Created by Alekseon" title="Created by Alekseon" /></a></div>';
15
+ }
16
+ }
app/code/community/Alekseon/ModulesConflictDetector/Block/Adminhtml/System/Config/Form/Field/AlekseonNotification.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Block_Adminhtml_System_Config_Form_Field_AlekseonNotification extends Mage_Adminhtml_Block_System_Config_Form_Field
9
+ {
10
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
11
+ {
12
+ $element->setValue(Mage::app()->loadCache(Alekseon_ModulesConflictDetector_Model_AlekseonAdminNotification_Feed::NOTIFICANTION_LASTCHECK_CACHE_KEY));
13
+ $format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
14
+ return Mage::app()->getLocale()->date(intval($element->getValue()))->toString($format);
15
+ }
16
+ }
app/code/community/Alekseon/ModulesConflictDetector/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+ public function getAlekseonUrl()
11
+ {
12
+ return 'http://www.alekseon.com';
13
+ }
14
+ }
app/code/community/Alekseon/ModulesConflictDetector/Model/AlekseonAdminNotification/Feed.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Model_AlekseonAdminNotification_Feed extends Mage_AdminNotification_Model_Feed
9
+ {
10
+ const XML_ENABLED_PATH = 'alekseon_adminNotification/general/enabled';
11
+ const XML_FREQUENCY_PATH = 'alekseon_adminNotification/general/frequency';
12
+ const NOTIFICANTION_LASTCHECK_CACHE_KEY = 'alekseon_notifications_lastcheck';
13
+
14
+ protected $_alekseonInstalledModules;
15
+
16
+ public function getFeedUrl()
17
+ {
18
+ if (is_null($this->_feedUrl)) {
19
+ $this->_feedUrl = Mage::helper('alekseon_modulesConflictDetector')->getAlekseonUrl() . '/rss/magento_rss.xml';
20
+ $query = '?utm_source=' . urlencode(Mage::getStoreConfig('web/unsecure/base_url'));
21
+ $query .= '&utm_medium=' . urlencode('Magento Connect');
22
+ $query .= '&utm_content=' . urlencode(Mage::getEdition() . ' ' . Mage::getVersion());
23
+ $query .= '&utm_term=' . urlencode(implode(',', $this->_getAlekseonInstalledModules()));
24
+
25
+ $this->_feedUrl .= $query;
26
+ }
27
+
28
+ return $this->_feedUrl;
29
+ }
30
+
31
+ public function checkUpdate()
32
+ {
33
+ if (!Mage::getStoreConfig(self::XML_ENABLED_PATH)) {
34
+ return $this;
35
+ }
36
+
37
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
38
+ return $this;
39
+ }
40
+
41
+ $feedData = array();
42
+ $feedXml = $this->getFeedData();
43
+
44
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
45
+ foreach ($feedXml->channel->item as $item) {
46
+
47
+ $module = (string)$item->module;
48
+ if ($module && !in_array($module, $this->_getAlekseonInstalledModules())) {
49
+ continue;
50
+ }
51
+
52
+ $feedData[] = array(
53
+ 'severity' => (int)$item->severity,
54
+ 'date_added' => $this->getDate((string)$item->pubDate),
55
+ 'title' => (string)$item->title,
56
+ 'description' => (string)$item->description,
57
+ 'url' => (string)$item->link,
58
+ );
59
+ }
60
+
61
+ if ($feedData) {
62
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
63
+ }
64
+
65
+ }
66
+ $this->setLastUpdate();
67
+
68
+ return $this;
69
+ }
70
+
71
+ public function getLastUpdate()
72
+ {
73
+ return Mage::app()->loadCache(self::NOTIFICANTION_LASTCHECK_CACHE_KEY);
74
+ }
75
+
76
+ public function setLastUpdate()
77
+ {
78
+ Mage::app()->saveCache(time(), self::NOTIFICANTION_LASTCHECK_CACHE_KEY);
79
+ return $this;
80
+ }
81
+
82
+ protected function _getAlekseonInstalledModules()
83
+ {
84
+ if (is_null($this->_alekseonInstalledModules)) {
85
+ $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
86
+ $this->_alekseonInstalledModules = array();
87
+ foreach ($modules as $moduleName) {
88
+ if (substr($moduleName, 0, 9) == 'Alekseon_'){
89
+ $this->_alekseonInstalledModules[] = $moduleName;
90
+ }
91
+ }
92
+ }
93
+ return $this->_alekseonInstalledModules;
94
+ }
95
+ }
app/code/community/Alekseon/ModulesConflictDetector/Model/AlekseonAdminNotification/Observer.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Model_AlekseonAdminNotification_Observer
9
+ {
10
+ public function preDispatch(Varien_Event_Observer $observer)
11
+ {
12
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
13
+ $feedModel = Mage::getModel('alekseon_modulesConflictDetector/alekseonAdminNotification_feed');
14
+ $feedModel->checkUpdate();
15
+ }
16
+
17
+ }
18
+ }
app/code/community/Alekseon/ModulesConflictDetector/Model/Resource/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Model_Resource_Collection extends Alekseon_ModulesConflictDetector_Model_Resource_NonDbCollection
9
+ {
10
+ }
app/code/community/Alekseon/ModulesConflictDetector/Model/Resource/NonDbCollection.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Model_Resource_NonDbCollection extends Varien_Data_Collection
9
+ {
10
+ protected $_filters = array();
11
+
12
+ public function addFieldToFilter($attribute, $condition=null)
13
+ {
14
+ if (isset($condition['eq'])) {
15
+ $value = $condition['eq'];
16
+ $method = 'equal';
17
+ } elseif (isset($condition['like'])) {
18
+ $value = $condition['like'];
19
+ $method = 'like';
20
+ }
21
+
22
+ $this->_filters[] = array(
23
+ 'attribute' => $attribute,
24
+ 'method' => $method,
25
+ 'value' => $value,
26
+ );
27
+ }
28
+
29
+ public function load($printQuery = false, $logQuery = false)
30
+ {
31
+ if ($this->isLoaded()) {
32
+ return $this;
33
+ }
34
+
35
+ $this->_addFilterToCollection();
36
+ $this->_sortCollection();
37
+ $this->_renderLimit();
38
+
39
+ $this->_setIsLoaded();
40
+ return $this;
41
+ }
42
+
43
+ public function getSize()
44
+ {
45
+ if (is_null($this->_totalRecords)) {
46
+ $this->_totalRecords = count($this->_items);
47
+ }
48
+ return intval($this->_totalRecords);
49
+ }
50
+
51
+ protected function _renderLimit()
52
+ {
53
+ if($this->_pageSize){
54
+ $from = ($this->getCurPage() - 1) * $this->_pageSize;
55
+ $to = ($this->getCurPage() - 1) * $this->_pageSize + $this->_pageSize - 1;
56
+ $items = $this->_items;
57
+ $this->_items = array();
58
+ $counter = 0;
59
+ foreach($items as $item) {
60
+ if ($counter >= $from && $counter <= $to) {
61
+ $this->addItem($item);
62
+ }
63
+ $counter++;
64
+ }
65
+ }
66
+
67
+ return $this;
68
+ }
69
+
70
+ protected function _sortCollection()
71
+ {
72
+ usort($this->_items , array($this, '_doCompare'));
73
+ return $this;
74
+ }
75
+
76
+ protected function _addFilterToCollection()
77
+ {
78
+ $items = $this->_items;
79
+ $this->_items = array();
80
+ foreach($items as $item) {
81
+ if ($this->_filterItem($item)) {
82
+ $this->addItem($item);
83
+ }
84
+ }
85
+ }
86
+
87
+ protected function _filterItem($item)
88
+ {
89
+ foreach ($this->_filters as $filter) {
90
+ $method = $filter['method'];
91
+ $attribute = $filter['attribute'];
92
+ $itemValue = $item[$attribute];
93
+
94
+ if (is_array($itemValue) && isset($itemValue['filter_condition'])) {
95
+ $itemValue = $itemValue['filter_condition'];
96
+ }
97
+
98
+ if (!$this->$method($itemValue, $filter['value'])) {
99
+ return false;
100
+ }
101
+ }
102
+
103
+ return true;
104
+ }
105
+
106
+ protected function _doCompare($a, $b)
107
+ {
108
+ foreach($this->_orders as $column => $order) {
109
+ $valueA = $a->getData($column);
110
+ $valueB = $b->getData($column);
111
+ if (is_array($valueA)) {
112
+ $valueA = implode(',', $valueA);
113
+ }
114
+ if (is_array($valueB)) {
115
+ $valueB = implode(',', $valueB);
116
+ }
117
+
118
+ $result = strcmp($valueA, $valueB);
119
+
120
+ if (strtolower($order) == 'asc') {
121
+ $result = -$result;
122
+ }
123
+
124
+ return $result;
125
+ }
126
+ return 0;
127
+ }
128
+
129
+ public function equal($filerValue, $needle)
130
+ {
131
+ return ($filerValue == $needle);
132
+ }
133
+
134
+ public function like($filerValue, $needle)
135
+ {
136
+ $needle = trim($needle, ' \'"%');
137
+ return stristr($filerValue, $needle);
138
+ }
139
+ }
app/code/community/Alekseon/ModulesConflictDetector/Model/Rewrites.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Model_Rewrites extends Mage_Core_Model_Abstract
9
+ {
10
+ const CONFLICT_TYPE = 'yes';
11
+ const NO_CONFLICT_TYPE = 'no';
12
+ const RESOLVED_CONFLICT_TYPE = 'resolved';
13
+
14
+ const CONFLICT_COLOR = 'red';
15
+ const NO_CONFLICT_COLOR = 'green';
16
+ const RESOLVED_CONFLICT_COLOR = 'grey';
17
+
18
+ const USE_CACHE = true;
19
+ const CACHE_TYPE = "config";
20
+ const CACHE_KEY = "ALEKSEON_MODULES_CONFLICTS";
21
+
22
+ public function useCache()
23
+ {
24
+ return Mage::app()->useCache(self::CACHE_TYPE) && self::USE_CACHE;
25
+ }
26
+
27
+ public function getTypes()
28
+ {
29
+ $types = array(
30
+ 'helper' => 'Helper',
31
+ 'block' => 'Block',
32
+ 'model' => 'Model',
33
+ );
34
+
35
+ return $types;
36
+ }
37
+
38
+ public function getConflictTypes()
39
+ {
40
+ $types = array(
41
+ self::NO_CONFLICT_TYPE => Mage::helper('alekseon_modulesConflictDetector')->__('No'),
42
+ self::CONFLICT_TYPE => Mage::helper('alekseon_modulesConflictDetector')->__('Yes'),
43
+ self::RESOLVED_CONFLICT_TYPE => Mage::helper('alekseon_modulesConflictDetector')->__('Resolved'),
44
+ );
45
+
46
+ return $types;
47
+ }
48
+
49
+ public function getRewritesCollection()
50
+ {
51
+ if ($this->useCache() && $cache = Mage::app()->loadCache(self::CACHE_KEY)) {
52
+ $collection = unserialize($cache);
53
+ } else {
54
+ $collection = Mage::getModel('alekseon_modulesConflictDetector/resource_collection');
55
+
56
+ foreach($this->_getRewritesArray() as $rewrite) {
57
+ $collection->addItem($rewrite);
58
+ }
59
+
60
+ if ($this->useCache()) {
61
+ Mage::app()->saveCache(serialize($collection), self::CACHE_KEY, array(self::CACHE_TYPE));
62
+ }
63
+ }
64
+
65
+ return $collection;
66
+ }
67
+
68
+ protected function _getRewritesArray()
69
+ {
70
+ $rewritesArray = array();
71
+
72
+ foreach($this->getTypes() as $type => $label) {
73
+ $rewrites = $this->_collectRewrites($type);
74
+ foreach($rewrites as $initialClass => $rewritesData) {
75
+ $rewriteItem = new Varien_Object();
76
+ $rewriteItem->setClass($initialClass);
77
+ $rewriteItem->setType($type);
78
+ $rewriteItem->setRewrites($rewritesData);
79
+ $rewriteItem->setConflict($this->_getConflict($rewritesData['classes']));
80
+
81
+ $rewritesArray[] = $rewriteItem;
82
+ }
83
+ }
84
+
85
+ return $rewritesArray;
86
+ }
87
+
88
+ protected function _collectRewrites($type)
89
+ {
90
+ $modelsRewrites = array();
91
+
92
+ $modules = Mage::getConfig()->getNode('modules')->children();
93
+ foreach ($modules as $modName=>$module) {
94
+ if (!$module->is('active')) {
95
+ continue;
96
+ }
97
+
98
+ $configFile = Mage::getConfig()->getModuleDir('etc', $modName) . DS . 'config.xml';
99
+ $moduleConfig = Mage::getModel('core/config_base');
100
+ $moduleConfig->loadFile($configFile);
101
+
102
+ $typeNode = $moduleConfig->getNode()->global->{$type.'s'};
103
+
104
+ if (!$typeNode) {
105
+ continue;
106
+ }
107
+
108
+ $nodes = $typeNode->children();
109
+ foreach($nodes as $nodeName => $config) {
110
+ $rewrites = $config->rewrite;
111
+
112
+ if ($rewrites) {
113
+ $classes = array();
114
+ foreach($rewrites->children() as $classId => $newClass) {
115
+ $classes[] = (string)$newClass;
116
+ $initialClass = $this->_getClassName($type, $nodeName, $classId);
117
+ $usedRewrite = $this->_getClassName($type, $nodeName, $classId, true);
118
+
119
+ $color = false;
120
+
121
+ if ($newClass == $usedRewrite) {
122
+ $color = self::NO_CONFLICT_COLOR;
123
+ $conflict = self::NO_CONFLICT_TYPE;
124
+ } elseif (is_subclass_of($usedRewrite, $newClass)) {
125
+ $color = self::RESOLVED_CONFLICT_COLOR;
126
+ $conflict = self::RESOLVED_CONFLICT_TYPE;
127
+ } else {
128
+ $color = self::CONFLICT_COLOR;
129
+ $conflict = self::CONFLICT_TYPE;
130
+ }
131
+
132
+ $modelsRewrites[$initialClass]['classes'][] = array(
133
+ 'class' => (string)$newClass,
134
+ 'color' => $color,
135
+ 'conflict' => $conflict,
136
+ );
137
+ if (!isset($modelsRewrites[$initialClass]['filter_condition'])) {
138
+ $modelsRewrites[$initialClass]['filter_condition'] = (string)$newClass . ',';
139
+ } else {
140
+ $modelsRewrites[$initialClass]['filter_condition'] .= (string)$newClass . ',';
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ return $modelsRewrites;
148
+ }
149
+
150
+ protected function _getClassName($type, $groupId, $classId, $rewrites = false)
151
+ {
152
+ $config = Mage::getConfig()->getNode()->global->{$type.'s'}->{$groupId};
153
+
154
+ if ($rewrites && isset($config->rewrite->$classId)) {
155
+ $className = (string)$config->rewrite->$classId;
156
+ } else {
157
+ if (!empty($config)) {
158
+ $className = $config->getClassName();
159
+ }
160
+ if (empty($className)) {
161
+ $className = 'mage_'.$groupId.'_'.$type;
162
+ }
163
+ if (!empty($classId)) {
164
+ $className .= '_'.$classId;
165
+ }
166
+ $className = uc_words($className);
167
+ }
168
+
169
+ return $className;
170
+ }
171
+
172
+ protected function _getConflict($rewritesData)
173
+ {
174
+ $conflict = self::NO_CONFLICT_TYPE;
175
+ foreach($rewritesData as $rewrite) {
176
+ if ($rewrite['conflict'] == self::CONFLICT_TYPE) {
177
+ return self::CONFLICT_TYPE;
178
+ } elseif ($rewrite['conflict'] == self::RESOLVED_CONFLICT_TYPE) {
179
+ $conflict = self::RESOLVED_CONFLICT_TYPE;
180
+ }
181
+ }
182
+ return $conflict;
183
+ }
184
+ }
app/code/community/Alekseon/ModulesConflictDetector/controllers/Adminhtml/ModulesConflictDetectorController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Marcin Frymark
4
+ * @email contact@alekseon.com
5
+ * @company Alekseon
6
+ * @website www.alekseon.com
7
+ */
8
+ class Alekseon_ModulesConflictDetector_Adminhtml_ModulesConflictDetectorController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+
11
+ public function indexAction()
12
+ {
13
+ if ($this->getRequest()->getQuery('ajax')) {
14
+ $this->_forward('grid');
15
+ return;
16
+ }
17
+
18
+ $this->loadLayout();
19
+ $this->_setActiveMenu('system/modules_conflict_detector');
20
+ $this->_addContent(
21
+ $this->getLayout()->createBlock('alekseon_modulesConflictDetector/adminhtml_rewrites', 'modules_rewrites')
22
+ );
23
+ $this->_addContent(
24
+ $this->getLayout()->createBlock('alekseon_modulesConflictDetector/adminhtml_explanations', 'explanations')
25
+ );
26
+ $this->renderLayout();
27
+ }
28
+
29
+ public function gridAction()
30
+ {
31
+ $this->loadLayout();
32
+ $this->getResponse()->setBody($this->getLayout()->createBlock('alekseon_modulesConflictDetector/adminhtml_rewrites_grid')->toHtml());
33
+ }
34
+ }
app/code/community/Alekseon/ModulesConflictDetector/etc/adminhtml.xml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Marcin Frymark
5
+ * @email contact@alekseon.com
6
+ * @company Alekseon
7
+ * @website www.alekseon.com
8
+ */
9
+ -->
10
+ <config>
11
+ <menu>
12
+ <system>
13
+ <children>
14
+ <alekseon_tools translate="title" module="alekseon_modulesConflictDetector">
15
+ <title>Alekseon Tools</title>
16
+ <sort_order>89</sort_order>
17
+ <children>
18
+ <modules_conflict_detector>
19
+ <title>Modules Conflict Detector</title>
20
+ <sort_order>10</sort_order>
21
+ <action>adminhtml/modulesConflictDetector</action>
22
+ </modules_conflict_detector>
23
+ </children>
24
+ </alekseon_tools>
25
+ </children>
26
+ </system>
27
+ </menu>
28
+ <acl>
29
+ <resources>
30
+ <admin>
31
+ <children>
32
+ <system>
33
+ <children>
34
+ <config>
35
+ <children>
36
+ <alekseon_adminNotification translate="title" module="alekseon_modulesConflictDetector">
37
+ <title>Alekseon Notifications</title>
38
+ <sort_order>10</sort_order>
39
+ </alekseon_adminNotification>
40
+ </children>
41
+ </config>
42
+ <alekseon_tools translate="title" module="alekseon_modulesConflictDetector">
43
+ <title>Alekseon Tools</title>
44
+ <sort_order>89</sort_order>
45
+ <children>
46
+ <modules_conflict_detector>
47
+ <title>Modules Conflict Detector</title>
48
+ <sort_order>10</sort_order>
49
+ </modules_conflict_detector>
50
+ </children>
51
+ </alekseon_tools>
52
+ </children>
53
+ </system>
54
+ </children>
55
+ </admin>
56
+ </resources>
57
+ </acl>
58
+ </config>
app/code/community/Alekseon/ModulesConflictDetector/etc/config.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Marcin Frymark
5
+ * @email contact@alekseon.com
6
+ * @company Alekseon
7
+ * @website www.alekseon.com
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Alekseon_ModulesConflictDetector>
13
+ <version>0.1.1</version>
14
+ </Alekseon_ModulesConflictDetector>
15
+ </modules>
16
+ <global>
17
+ <helpers>
18
+ <alekseon_modulesConflictDetector>
19
+ <class>Alekseon_ModulesConflictDetector_Helper</class>
20
+ </alekseon_modulesConflictDetector>
21
+ </helpers>
22
+ <blocks>
23
+ <alekseon_modulesConflictDetector>
24
+ <class>Alekseon_ModulesConflictDetector_Block</class>
25
+ </alekseon_modulesConflictDetector>
26
+ </blocks>
27
+ <models>
28
+ <alekseon_modulesConflictDetector>
29
+ <class>Alekseon_ModulesConflictDetector_Model</class>
30
+ </alekseon_modulesConflictDetector>
31
+ </models>
32
+ </global>
33
+ <admin>
34
+ <routers>
35
+ <adminhtml>
36
+ <args>
37
+ <modules>
38
+ <alekseon_modulesConflictDetector before="Mage_Adminhtml">Alekseon_ModulesConflictDetector_Adminhtml</alekseon_modulesConflictDetector>
39
+ </modules>
40
+ </args>
41
+ </adminhtml>
42
+ </routers>
43
+ </admin>
44
+ <adminhtml>
45
+ <events>
46
+ <controller_action_predispatch>
47
+ <observers>
48
+ <alekseon_adminNotification>
49
+ <class>alekseon_modulesConflictDetector/alekseonAdminNotification_observer</class>
50
+ <method>preDispatch</method>
51
+ </alekseon_adminNotification>
52
+ </observers>
53
+ </controller_action_predispatch>
54
+ </events>
55
+ </adminhtml>
56
+ <default>
57
+ <alekseon_adminNotification>
58
+ <general>
59
+ <enabled>1</enabled>
60
+ <frequency>12</frequency>
61
+ </general>
62
+ </alekseon_adminNotification>
63
+ </default>
64
+ </config>
app/code/community/Alekseon/ModulesConflictDetector/etc/system.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Marcin Frymark
5
+ * @email contact@alekseon.com
6
+ * @company Alekseon
7
+ * @website www.alekseon.com
8
+ */
9
+ -->
10
+ <config>
11
+ <tabs>
12
+ <alekseon>
13
+ <label>Alekseon</label>
14
+ <sort_order>450</sort_order>
15
+ </alekseon>
16
+ </tabs>
17
+ <sections>
18
+ <alekseon_adminNotification translate="label" module="alekseon_modulesConflictDetector">
19
+ <label>Alekseon Notifications</label>
20
+ <tab>alekseon</tab>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>0</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <groups>
27
+ <hint>
28
+ <frontend_model>alekseon_modulesConflictDetector/adminhtml_system_config_form_field_alekseonLogo</frontend_model>
29
+ <sort_order>0</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </hint>
34
+ <general translate="label">
35
+ <label>General Options</label>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>10</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>0</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ <fields>
42
+ <enabled translate="label">
43
+ <label>Enabled</label>
44
+ <source_model>adminhtml/system_config_source_yesno</source_model>
45
+ <frontend_type>select</frontend_type>
46
+ <sort_order>10</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>0</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ </enabled>
51
+ <frequency translate="label">
52
+ <label>Update Frequency</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>adminhtml/system_config_source_notification_frequency</source_model>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>0</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </frequency>
60
+ <last_update translate="label">
61
+ <label>Last Update</label>
62
+ <frontend_type>label</frontend_type>
63
+ <frontend_model>alekseon_modulesConflictDetector/adminhtml_system_config_form_field_alekseonNotification</frontend_model>
64
+ <sort_order>30</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>0</show_in_website>
67
+ <show_in_store>0</show_in_store>
68
+ </last_update>
69
+ </fields>
70
+ </general>
71
+ </groups>
72
+ </alekseon_adminNotification>
73
+ </sections>
74
+ </config>
app/design/adminhtml/default/default/template/alekseon/modulesConflictDetector/explanations.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <div class="box box-right">
2
+ <b><?php echo $this->__('Rewrites Explanations:') ?></b>
3
+ <ul class="note-list">
4
+ <li><span style="color:<?php echo $this->getNoConflictColor() ?>"><?php echo $this->__('Green class name') ?></span> <?php echo $this->__('means that this class is currently used instead of initial class.') ?></li>
5
+ <li><span style="color:<?php echo $this->getConflictResolvedColor() ?>"><?php echo $this->__('Gray class name') ?></span> <?php echo $this->__('means that currently used class (\'green one\') extends this class.') ?></li>
6
+ <li><span style="color:<?php echo $this->getConflictColor() ?>"><?php echo $this->__('Red class name') ?></span> <?php echo $this->__('means that probably there is conflict, initial class has been overwritten by this class, but this class is not used. You should check if this class doesn\'t contain any important methods or changes, which should be used.') ?></li>
7
+ </ul>
8
+ </div>
9
+ <div class="clear"></div>
app/etc/modules/Alekseon_ModulesConflictDetector.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Marcin Frymark
5
+ * @email contact@alekseon.com
6
+ * @company Alekseon
7
+ * @website www.alekseon.com
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Alekseon_ModulesConflictDetector>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Alekseon_ModulesConflictDetector>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>modules_conflict_detector</name>
4
+ <version>0.1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Check if you don't have any conflicts in rewrites between installed modules.</summary>
10
+ <description>Check if you don't have any conflicts in rewrites between installed modules.</description>
11
+ <notes>Check if you don't have any conflicts in rewrites between installed modules.</notes>
12
+ <authors><author><name>Marcin Frymark</name><user>Alekseon</user><email>contact@alekseon.com</email></author></authors>
13
+ <date>2014-03-23</date>
14
+ <time>10:42:42</time>
15
+ <contents><target name="magecommunity"><dir name="Alekseon"><dir name="ModulesConflictDetector"><dir><dir name="Block"><dir name="Adminhtml"><file name="Explanations.php" hash="0a8cd813571b686b427307494d826fc6"/><dir name="Rewrites"><dir name="Grid"><dir name="Renderer"><file name="DetailsButton.php" hash="753b63ad8085bbd3548de5abde49d7fa"/><file name="Rewrites.php" hash="af21f07ab44dca9154185fd0c67dfd31"/></dir></dir><file name="Grid.php" hash="845bafca998a83cb7a87ee014c8f6955"/></dir><file name="Rewrites.php" hash="8ab82af5797da19d5313940164a4d178"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="AlekseonLogo.php" hash="80da1af8a2e13d2060344b3d3847556e"/><file name="AlekseonNotification.php" hash="e23d75a2055777ac9f22d8f1ffd4114e"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2c25602ee805b609b3d3a46b1c1aa589"/></dir><dir name="Model"><dir name="AlekseonAdminNotification"><file name="Feed.php" hash="6faab757204424af0d927a176ed8bfa1"/><file name="Observer.php" hash="ac86f372eae98573fe3527b09e046e03"/></dir><dir name="Resource"><file name="Collection.php" hash="80df48d43334019dfa1a29e100769d67"/><file name="NonDbCollection.php" hash="399f998feb9460665f5426d0a3306723"/></dir><file name="Rewrites.php" hash="bc72d847d12494fa7a8874496d62cd1e"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ModulesConflictDetectorController.php" hash="23c14b7da46203a1541691fe236829cf"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6e508d19181289bde12dcff8c72e01dc"/><file name="config.xml" hash="44eeaed1dcf934bc9a6757c4f87f5680"/><file name="system.xml" hash="2e87963d966b5190906bbb282564855b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Alekseon_ModulesConflictDetector.xml" hash="a398b22450033be787cd8e0b990589ed"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="alekseon"><dir name="modulesConflictDetector"><file name="explanations.phtml" hash="5dac6251ba74bce38b92d1b809848bbf"/></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>