├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── doc ├── Manual.rst ├── TD_SystemConfigDiff_Doku.pdf ├── systemconfigdiff.png └── wsi.png ├── modman └── src ├── app ├── code │ └── community │ │ └── TechDivision │ │ └── SystemConfigDiff │ │ ├── Block │ │ └── Adminhtml │ │ │ ├── Overview.php │ │ │ ├── Overview │ │ │ ├── Edit │ │ │ │ └── Form.php │ │ │ ├── Tabs.php │ │ │ └── Tabs │ │ │ │ ├── Abstract.php │ │ │ │ ├── Block.php │ │ │ │ ├── Config.php │ │ │ │ ├── Page.php │ │ │ │ └── SystemConfig.php │ │ │ └── System │ │ │ └── Config │ │ │ └── Form │ │ │ ├── Field.php │ │ │ └── Field │ │ │ ├── Array │ │ │ └── Abstract.php │ │ │ └── Regexceptions.php │ │ ├── Helper │ │ ├── Config.php │ │ ├── Config │ │ │ └── Abstract.php │ │ └── Data.php │ │ ├── Model │ │ ├── Block.php │ │ ├── Config.php │ │ ├── Differ.php │ │ ├── Differ │ │ │ ├── Cms.php │ │ │ └── Config.php │ │ ├── Observer.php │ │ ├── Page.php │ │ ├── Resource │ │ │ ├── Block.php │ │ │ ├── Block │ │ │ │ └── Collection.php │ │ │ ├── Config.php │ │ │ ├── Config │ │ │ │ └── Collection.php │ │ │ ├── Page.php │ │ │ ├── Page │ │ │ │ └── Collection.php │ │ │ └── Setup.php │ │ ├── Service │ │ │ ├── Api.php │ │ │ └── Api │ │ │ │ └── V2.php │ │ ├── System │ │ │ └── Config │ │ │ │ └── Source │ │ │ │ └── Paths.php │ │ └── SystemDiff.php │ │ ├── controllers │ │ └── Adminhtml │ │ │ └── IndexController.php │ │ ├── etc │ │ ├── api.xml │ │ ├── config.xml │ │ ├── system.xml │ │ ├── wsdl.xml │ │ └── wsi.xml │ │ └── sql │ │ └── techdivision_systemconfigdiff_setup │ │ └── mysql4-install-0.1.0beta.php ├── design │ └── adminhtml │ │ └── default │ │ └── default │ │ ├── layout │ │ └── techdivision │ │ │ └── systemconfigdiff.xml │ │ └── template │ │ └── techdivision │ │ └── systemconfigdiff │ │ ├── switcher.phtml │ │ └── tabs.phtml ├── etc │ └── modules │ │ └── TechDivision_SystemConfigDiff.xml └── locale │ ├── de_DE │ └── TechDivision_SystemConfigDiff.csv │ └── en_US │ └── TechDivision_SystemConfigDiff.csv ├── dev └── tests │ ├── integration │ └── testsuite │ │ └── TechDivision │ │ └── SystemConfigDiff │ │ └── DummyTest.php │ └── unit │ └── testsuite │ └── TechDivision │ └── SystemConfigDiff │ └── DummyTest.php └── skin └── adminhtml └── default └── default ├── css └── techdivision │ └── systemconfigdiff │ └── diff.css ├── images └── techdivision │ └── systemconfigdiff │ ├── bkg_icon-replacebtn.png │ ├── bkg_icon-resetbtn-disabled.png │ └── selectDiffError.png └── js └── techdivision └── systemconfigdiff ├── diff.js └── jquery-1.9.1.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.buildpath 2 | /.project 3 | /.settings 4 | /.idea 5 | /build 6 | /build.properties 7 | /composer.lock 8 | /instance-src 9 | /target 10 | /output 11 | /build.default.properties 12 | 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Open Software License v. 3.0 (OSL-3.0) 2 | 3 | This Open Software License (the "License") applies to any original work of 4 | authorship (the "Original Work") whose owner (the "Licensor") has placed the 5 | following licensing notice adjacent to the copyright notice for the Original 6 | Work: 7 | 8 | Licensed under the Open Software License version 3.0 9 | 10 | 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, 11 | non-exclusive, sublicensable license, for the duration of the copyright, to do 12 | the following: 13 | 14 | a) to reproduce the Original Work in copies, either alone or as part of a 15 | collective work; 16 | 17 | b) to translate, adapt, alter, transform, modify, or arrange the Original Work, 18 | thereby creating derivative works ("Derivative Works") based upon the Original 19 | Work; 20 | 21 | c) to distribute or communicate copies of the Original Work and Derivative 22 | Works to the public, with the proviso that copies of Original Work or 23 | Derivative Works that You distribute or communicate shall be licensed under 24 | this Open Software License; 25 | 26 | d) to perform the Original Work publicly; and 27 | 28 | e) to display the Original Work publicly. 29 | 30 | 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, 31 | non-exclusive, sublicensable license, under patent claims owned or controlled 32 | by the Licensor that are embodied in the Original Work as furnished by the 33 | Licensor, for the duration of the patents, to make, use, sell, offer for sale, 34 | have made, and import the Original Work and Derivative Works. 35 | 36 | 3) Grant of Source Code License. The term "Source Code" means the preferred 37 | form of the Original Work for making modifications to it and all available 38 | documentation describing how to modify the Original Work. Licensor agrees to 39 | provide a machine-readable copy of the Source Code of the Original Work along 40 | with each copy of the Original Work that Licensor distributes. Licensor 41 | reserves the right to satisfy this obligation by placing a machine-readable 42 | copy of the Source Code in an information repository reasonably calculated to 43 | permit inexpensive and convenient access by You for as long as Licensor 44 | continues to distribute the Original Work. 45 | 46 | 4) Exclusions From License Grant. Neither the names of Licensor, nor the names 47 | of any contributors to the Original Work, nor any of their trademarks or 48 | service marks, may be used to endorse or promote products derived from this 49 | Original Work without express prior permission of the Licensor. Except as 50 | expressly stated herein, nothing in this License grants any license to 51 | Licensor's trademarks, copyrights, patents, trade secrets or any other 52 | intellectual property. No patent license is granted to make, use, sell, offer 53 | for sale, have made, or import embodiments of any patent claims other than the 54 | licensed claims defined in Section 2. No license is granted to the trademarks 55 | of Licensor even if such marks are included in the Original Work. Nothing in 56 | this License shall be interpreted to prohibit Licensor from licensing under 57 | terms different from this License any Original Work that Licensor otherwise 58 | would have a right to license. 59 | 60 | 5) External Deployment. The term "External Deployment" means the use, 61 | distribution, or communication of the Original Work or Derivative Works in any 62 | way such that the Original Work or Derivative Works may be used by anyone other 63 | than You, whether those works are distributed or communicated to those persons 64 | or made available as an application intended for use over a network. As an 65 | express condition for the grants of license hereunder, You must treat any 66 | External Deployment by You of the Original Work or a Derivative Work as a 67 | distribution under section 1(c). 68 | 69 | 6) Attribution Rights. You must retain, in the Source Code of any Derivative 70 | Works that You create, all copyright, patent, or trademark notices from the 71 | Source Code of the Original Work, as well as any notices of licensing and any 72 | descriptive text identified therein as an "Attribution Notice." You must cause 73 | the Source Code for any Derivative Works that You create to carry a prominent 74 | Attribution Notice reasonably calculated to inform recipients that You have 75 | modified the Original Work. 76 | 77 | 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that 78 | the copyright in and to the Original Work and the patent rights granted herein 79 | by Licensor are owned by the Licensor or are sublicensed to You under the terms 80 | of this License with the permission of the contributor(s) of those copyrights 81 | and patent rights. Except as expressly stated in the immediately preceding 82 | sentence, the Original Work is provided under this License on an "AS IS" BASIS 83 | and WITHOUT WARRANTY, either express or implied, including, without limitation, 84 | the warranties of non-infringement, merchantability or fitness for a particular 85 | purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. 86 | This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No 87 | license to the Original Work is granted by this License except under this 88 | disclaimer. 89 | 90 | 8) Limitation of Liability. Under no circumstances and under no legal theory, 91 | whether in tort (including negligence), contract, or otherwise, shall the 92 | Licensor be liable to anyone for any indirect, special, incidental, or 93 | consequential damages of any character arising as a result of this License or 94 | the use of the Original Work including, without limitation, damages for loss of 95 | goodwill, work stoppage, computer failure or malfunction, or any and all other 96 | commercial damages or losses. This limitation of liability shall not apply to 97 | the extent applicable law prohibits such limitation. 98 | 99 | 9) Acceptance and Termination. If, at any time, You expressly assented to this 100 | License, that assent indicates your clear and irrevocable acceptance of this 101 | License and all of its terms and conditions. If You distribute or communicate 102 | copies of the Original Work or a Derivative Work, You must make a reasonable 103 | effort under the circumstances to obtain the express assent of recipients to 104 | the terms of this License. This License conditions your rights to undertake the 105 | activities listed in Section 1, including your right to create Derivative Works 106 | based upon the Original Work, and doing so without honoring these terms and 107 | conditions is prohibited by copyright law and international treaty. Nothing in 108 | this License is intended to affect copyright exceptions and limitations 109 | (including "fair use" or "fair dealing"). This License shall terminate 110 | immediately and You may no longer exercise any of the rights granted to You by 111 | this License upon your failure to honor the conditions in Section 1(c). 112 | 113 | 10) Termination for Patent Action. This License shall terminate automatically 114 | and You may no longer exercise any of the rights granted to You by this License 115 | as of the date You commence an action, including a cross-claim or counterclaim, 116 | against Licensor or any licensee alleging that the Original Work infringes a 117 | patent. This termination provision shall not apply for an action alleging 118 | patent infringement by combinations of the Original Work with other software or 119 | hardware. 120 | 121 | 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this 122 | License may be brought only in the courts of a jurisdiction wherein the 123 | Licensor resides or in which Licensor conducts its primary business, and under 124 | the laws of that jurisdiction excluding its conflict-of-law provisions. The 125 | application of the United Nations Convention on Contracts for the International 126 | Sale of Goods is expressly excluded. Any use of the Original Work outside the 127 | scope of this License or after its termination shall be subject to the 128 | requirements and penalties of copyright or patent law in the appropriate 129 | jurisdiction. This section shall survive the termination of this License. 130 | 131 | 12) Attorneys' Fees. In any action to enforce the terms of this License or 132 | seeking damages relating thereto, the prevailing party shall be entitled to 133 | recover its costs and expenses, including, without limitation, reasonable 134 | attorneys' fees and costs incurred in connection with such action, including 135 | any appeal of such action. This section shall survive the termination of this 136 | License. 137 | 138 | 13) Miscellaneous. If any provision of this License is held to be 139 | unenforceable, such provision shall be reformed only to the extent necessary to 140 | make it enforceable. 141 | 142 | 14) Definition of "You" in This License. "You" throughout this License, whether 143 | in upper or lower case, means an individual or a legal entity exercising rights 144 | under, and complying with all of the terms of, this License. For legal 145 | entities, "You" includes any entity that controls, is controlled by, or is 146 | under common control with you. For purposes of this definition, "control" means 147 | (i) the power, direct or indirect, to cause the direction or management of such 148 | entity, whether by contract or otherwise, or (ii) ownership of fifty percent 149 | (50%) or more of the outstanding shares, or (iii) beneficial ownership of such 150 | entity. 151 | 152 | 15) Right to Use. You may use the Original Work in all ways not otherwise 153 | restricted or conditioned by this License or by law, and Licensor promises not 154 | to interfere with or be responsible for such uses by You. 155 | 156 | 16) Modification of This License. This License is Copyright © 2005 Lawrence 157 | Rosen. Permission is granted to copy, distribute, or communicate this License 158 | without modification. Nothing in this License permits You to modify this 159 | License as applied to the Original Work or to Derivative Works. However, You 160 | may modify the text of this License and copy, distribute or communicate your 161 | modified version (the "Modified License") and apply it to other original works 162 | of authorship subject to the following conditions: (i) You may not indicate in 163 | any way that your Modified License is the "Open Software License" or "OSL" and 164 | you may not use those names in the name of your Modified License; (ii) You must 165 | replace the notice specified in the first paragraph above with the notice 166 | "Licensed under " or with a notice of your own 167 | that is not confusingly similar to the notice in this License; and (iii) You 168 | may not claim that your original works are open source software unless your 169 | Modified License has been approved by Open Source Initiative (OSI) and You 170 | comply with its license review and certification process. 171 | 172 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TechDivision_SystemConfigDiff 2 | ============================= 3 | Module to diff a remote Magento system configuration and CMS blocks/pages and sync values. 4 | Please feel free to participate in further development of this module. It is easily extendable 5 | as you can read under developer documentation. Any feedback is welcome! 6 | 7 | 8 | Features 9 | - 10 | * System configuration diff 11 | * CMS pages diff 12 | * CMS blocks diff 13 | * Table overview for diffs 14 | * Easy and intuitive diff displaying in the system configuration 15 | * Differentiates between all scopes 16 | * Synchronisation between both systems 17 | * Cron job functionality to update diffs automatically 18 | 19 | See our video illustrating the features: http://www.youtube.com/watch?v=VDh75aaE01c 20 | 21 | ![System config diff](https://raw.github.com/techdivision/TechDivision_SystemConfigDiff/github/doc/systemconfigdiff.png) 22 | 23 | Purpose 24 | - 25 | The purpose of the module is to create and display a diff of the system 26 | configuration, cms blocks and cms pages of two different system 27 | instances. The module requests via a Magento API extension the system 28 | data of the configured reference system the data gets compared with. It 29 | saves all diffs and can display them in the system configuration. There 30 | you can replace the config value with the value from the other system 31 | with just one click. It can differentiate between all scopes (default, 32 | websites, stores) as well as between all scope instances (the different 33 | websites, stores). 34 | 35 | 36 | Developer documentation 37 | - 38 | All templates, css and js will be injected via an observer before the layout 39 | gets rendered. Unfortunately the HTML code for the config fields is hard 40 | coded in PHP so `Mage_Adminhtml_Block_System_Config_Form_Field` had to be 41 | rewritten as well as a child class called 42 | `Mage_Adminhtml_Block_System_Config_Form_Field_Regexceptions` because rewrites 43 | don't support class inheritance. 44 | The module comes with two differs: One is for the system configuration, the other 45 | is for cms blocks and cms pages. The module can easily be extended with more 46 | differs. Therefore you need to define a new differ in the config.xml under 47 | ``. The differ class should derive from 48 | `TechDivision_SystemConfigDiff_Model_Differ` and has to implement the following 49 | two functions: 50 | 51 | * `function diff($thisConfig, $otherConfig)` calculates the diff of two arrays of system data 52 | * `function getSystemData()` returns the system data for one system (i.e. at the webservice call) 53 | 54 | 55 | System Configuration 56 | - 57 | On the reference system you have to configure a webservice user which has 58 | sufficient rights for *System Config/Getting Config*. On the other system 59 | you have to configure the api settings. As the module uses version 2 of the API 60 | you have to use the following URL: `http://magentohost/api/v2_soap/?wsdl=1`. 61 | You can define aliases for both systems for displaying the diffs. Also you 62 | can turn on/off the diff display in the system configuration. Optionally you 63 | can declare ignore paths which will not be shown as diff in system configuration. 64 | This could be helpful for paths where you are sure they will never be the same 65 | like the base url. 66 | 67 | 68 | Compatibility 69 | - 70 | The extension is compatible without problems for the following versions: 71 | * Community >= 1.7.0.0 72 | * Enterprise >= 1.12.0.0 73 | 74 | Unfortunately lower versions are not compatible because of a Magento core bug. If you have set 75 | your webservice configuration to WSI-compliance mode, this bug will occur. The error message 76 | is `It looks like we got no XML document`. There is a fix for this: Copy `Mage_Api_Model_Server_WSI_Adapter_Soap` 77 | from the core codepool to the local codepool and remove the lines in the else branch marked in the picture: 78 | 79 | ![WSI Core Bug Fix](https://raw.github.com/techdivision/TechDivision_SystemConfigDiff/github/doc/wsi.png) 80 | 81 | We have to add that the use of this fix is totally at your own responsibility, we are not responsible for any 82 | damage caused by this fix. -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "techdivision/systemconfigdiff", 3 | "description": "Module to diff a remote Magento system configuration and CMS blocks/pages and sync values.", 4 | "type": "magento-module", 5 | "license": "OSL-3.0", 6 | "require": { 7 | "magento-hackathon/magento-composer-installer": "*" 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /doc/Manual.rst: -------------------------------------------------------------------------------- 1 | ================================================ 2 | Manual for Module TechDivision_SystemConfigDiff 3 | ================================================ 4 | 5 | .. contents:: 6 | 7 | .. section-numbering:: 8 | 9 | .. header:: 10 | 11 | Manual for TechDivision_SystemConfigDiff 12 | 13 | .. footer:: 14 | 15 | Page ###Page### of ###Total### 16 | 17 | 18 | Metadata 19 | ======== 20 | 21 | +---------------------------+------------------------------------------+ 22 | | Module Name | TechDivision_SystemConfigDiff | 23 | +---------------------------+------------------------------------------+ 24 | | Documented Module Version | 0.1.0beta | 25 | +---------------------------+------------------------------------------+ 26 | | Documentation Date | April 10, 2013 | 27 | +---------------------------+------------------------------------------+ 28 | | Module Developer(s) | Florian Sydekum (fs@techdivision.com) | 29 | +---------------------------+------------------------------------------+ 30 | | Documentation Author(s) | Florian Sydekum (fs@techdivision.com) | 31 | +---------------------------+------------------------------------------+ 32 | | PEAR Channel | connect.techdivision.com | 33 | +---------------------------+------------------------------------------+ 34 | 35 | 36 | Purpose 37 | ======= 38 | 39 | The purpose of the module is to create and display a diff of the system 40 | configuration, cms blocks and cms pages of two different system instances. 41 | The module requests via a Magento API extension the system data of the 42 | configured reference system the data gets compared with. It saves all 43 | diffs and can display them in the system configuration. There you can 44 | replace the config value with the value from the other system with just 45 | one click. It can differentiate between all scopes (default, websites, 46 | stores) as well as between all scope instances (the different websites, 47 | stores). 48 | 49 | 50 | Developer documentation 51 | ======================= 52 | 53 | All templates, css and js will be injected via an observer before the layout 54 | gets rendered. Unfortunately the HTML code for the config fields is hard 55 | coded in PHP so 'Mage_Adminhtml_Block_System_Config_Form_Field' had to be 56 | rewritten as well as a child class called 57 | *Mage_Adminhtml_Block_System_Config_Form_Field_Regexceptions* because rewrites 58 | don't support class inheritance. 59 | The module comes with two differs: One is for the system configuration, the other 60 | is for cms blocks and cms pages. The module can easily be extended with more 61 | differs. Therefore you need to define a new differ in the config.xml under 62 | **. The differ class should derive from 63 | *TechDivision_SystemConfigDiff_Model_Differ* and has to implement the following 64 | two functions: 65 | - function diff($thisConfig, $otherConfig): Calculates the diff of two arrays 66 | of system data 67 | - function getSystemData(): Returns the system data for one system (i.e. at 68 | the webservice call) 69 | 70 | 71 | Installation 72 | ============ 73 | 74 | Installing from scratch 75 | ----------------------- 76 | 77 | The installation of the module is done by simply installing the pear 78 | package connect.techdivision.com/Techdivision_SystemConfigDiff. 79 | No manual modification of any files is necessary for the module to 80 | function properly. 81 | 82 | 83 | System Configuration 84 | ==================== 85 | 86 | On the reference system you have to configure a webservice user which has 87 | sufficient rights for *System Config/Getting Config*. On the other system 88 | you have to configure the api settings. As the module uses version 2 of the API 89 | you have to use the following URL: http://magentohost/api/v2_soap/?wsdl=1. 90 | You can define aliases for both systems for displaying the diffs. Also you 91 | can turn on/off the diff display in the system configuration. Optionally you 92 | can declare ignore paths which will not be shown as diff in system configuration. 93 | This could be helpful for paths where you are sure they will never be the same 94 | like the base url. 95 | 96 | TechDivision SystemConfigDiff Systemsettings 97 | -------------------------------------------- 98 | 99 | +-----------------+-----------------+-------------------+ 100 | | **Option Name** | **Input Type** | **Default Value** | 101 | +-----------------+-----------------+-------------------+ 102 | | System URL | text | | 103 | +-----------------+-----------------+-------------------+ 104 | | API user | text | | 105 | +-----------------+-----------------+-------------------+ 106 | | API password | text | | 107 | +-----------------+-----------------+-------------------+ 108 | 109 | 110 | TechDivision SystemConfigDiff Displaysettings 111 | --------------------------------------------- 112 | 113 | +----------------------------+-----------------+-------------------+ 114 | | **Option Name** | **Input Type** | **Default Value** | 115 | +----------------------------+-----------------+-------------------+ 116 | | Alias for this system | text | | 117 | +----------------------------+-----------------+-------------------+ 118 | | Alias for other system | text | | 119 | +----------------------------+-----------------+-------------------+ 120 | | Show diff in system config | yes/no | *no* | 121 | +----------------------------+-----------------+-------------------+ 122 | | Ignore paths | multiselect | | 123 | +----------------------------+-----------------+-------------------+ -------------------------------------------------------------------------------- /doc/TD_SystemConfigDiff_Doku.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/doc/TD_SystemConfigDiff_Doku.pdf -------------------------------------------------------------------------------- /doc/systemconfigdiff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/doc/systemconfigdiff.png -------------------------------------------------------------------------------- /doc/wsi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/doc/wsi.png -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | # TechDivision_SystemConfigDiff 2 | src/app/code/community/TechDivision/SystemConfigDiff/ app/code/community/TechDivision/SystemConfigDiff/ 3 | src/app/design/adminhtml/default/default/layout/techdivision/* app/design/adminhtml/default/default/layout/techdivision/ 4 | src/app/design/adminhtml/default/default/template/techdivision/* app/design/adminhtml/default/default/template/techdivision/ 5 | src/app/etc/modules/* app/etc/modules/ 6 | src/app/locale/de_DE/* app/locale/de_DE/ 7 | src/app/locale/en_US/* app/locale/en_US/ 8 | src/skin/adminhtml/default/default/css/* skin/adminhtml/default/default/css/ 9 | src/skin/adminhtml/default/default/images/* skin/adminhtml/default/default/images/ 10 | src/skin/adminhtml/default/default/js/* skin/adminhtml/default/default/js/ 11 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview 25 | extends Mage_Adminhtml_Block_Widget_Form_Container 26 | { 27 | 28 | public function __construct() 29 | { 30 | parent::__construct(); 31 | 32 | $this->setId('diff_edit'); 33 | $this->_objectId = 'id'; 34 | $this->_blockGroup = 'techdivision_systemconfigdiff'; 35 | $this->_controller = 'adminhtml_overview'; 36 | $this->removeButton('save'); 37 | $this->removeButton('delete'); 38 | $this->removeButton('reset'); 39 | $this->removeButton('back'); 40 | $this->_addButton('new', array( 41 | 'label' => $this->defaultHelper()->__('New diff'), 42 | 'onclick' => 'self.location.href=\'' . $this->getUrl('*/*/new') . '\'', 43 | 'class' => 'save', 44 | ), -100, 20); 45 | 46 | $message = Mage::helper('techdivision_systemconfigdiff')->__('All diffs will be replaced by the data of the other system! Are you sure to proceed?'); 47 | $replaceAllData = array( 48 | 'label' => $this->defaultHelper()->__('Replace all'), 49 | 'onclick' => 'confirmSetLocation(\''.$message.'\', \'' . $this->getUrl('*/*/replaceAll') . '\')', 50 | 'class' => 'btn-reset' 51 | ); 52 | 53 | if(!$this->defaultHelper()->diffsAvailable()){ 54 | $replaceAllData['disabled'] = 'disabled'; 55 | } 56 | 57 | $this->_addButton('replaceAll', $replaceAllData, -100, 10); 58 | } 59 | 60 | /** 61 | * Returns the default helper instance. 62 | * 63 | * @return TechDivision_SystemConfigDiff_Helper_Data 64 | * The helper instance 65 | */ 66 | public function defaultHelper() 67 | { 68 | return Mage::helper('techdivision_systemconfigdiff'); 69 | } 70 | 71 | public function getHeaderText() 72 | { 73 | return $this->defaultHelper()->__('System diff'); 74 | } 75 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Edit/Form.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Edit_Form 25 | extends Mage_Adminhtml_Block_Widget_Form 26 | { 27 | protected function _prepareForm() 28 | { 29 | $form = new Varien_Data_Form( 30 | array( 31 | 'id' => 'edit_form', 32 | 'enctype' => 'multipart/form-data' 33 | ) 34 | ); 35 | 36 | $form->setUseContainer(true); 37 | $this->setForm($form); 38 | 39 | return parent::_prepareForm(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs 25 | extends Mage_Adminhtml_Block_Widget_Tabs 26 | { 27 | /** 28 | * Constructs the tabs section 29 | */ 30 | public function __construct() 31 | { 32 | parent::__construct(); 33 | $this->setId('diff_tabs'); 34 | $this->setDestElementId('edit_form'); 35 | $this->setTitle($this->defaultHelper()->__('System diff')); 36 | } 37 | 38 | /** 39 | * Adds the tabs with ajax class and ajax urls 40 | * 41 | * @return Mage_Core_Block_Abstract 42 | */ 43 | protected function _beforeToHtml() 44 | { 45 | $this->addTab('system_config_diff', array( 46 | 'label' => $this->defaultHelper()->__('System Config (system.xml)'), 47 | 'title' => $this->defaultHelper()->__('System Config (system.xml)'), 48 | 'url' => $this->getUrl('*/*/systemGrid', array('_current' => true)), 49 | 'class' => 'ajax', 50 | )); 51 | 52 | $this->addTab('config_diff', array( 53 | 'label' => $this->defaultHelper()->__('Config (config.xml and more)'), 54 | 'title' => $this->defaultHelper()->__('Config (config.xml and more)'), 55 | 'url' => $this->getUrl('*/*/configGrid', array('_current' => true)), 56 | 'class' => 'ajax', 57 | )); 58 | 59 | $this->addTab('page_diff', array( 60 | 'label' => $this->defaultHelper()->__('CMS Pages'), 61 | 'title' => $this->defaultHelper()->__('CMS Pages'), 62 | 'url' => $this->getUrl('*/*/pageGrid', array('_current' => true)), 63 | 'class' => 'ajax', 64 | )); 65 | 66 | $this->addTab('block_diff', array( 67 | 'label' => $this->defaultHelper()->__('CMS Blocks'), 68 | 'title' => $this->defaultHelper()->__('CMS Blocks'), 69 | 'url' => $this->getUrl('*/*/blockGrid', array('_current' => true)), 70 | 'class' => 'ajax', 71 | )); 72 | 73 | return parent::_beforeToHtml(); 74 | } 75 | 76 | /** 77 | * Returns the default helper instance. 78 | * 79 | * @return TechDivision_SystemConfigDiff_Helper_Data 80 | * The helper instance 81 | */ 82 | public function defaultHelper() 83 | { 84 | return Mage::helper('techdivision_systemconfigdiff'); 85 | } 86 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs/Abstract.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | abstract class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs_Abstract 25 | extends Mage_Adminhtml_Block_Widget_Form 26 | implements Mage_Adminhtml_Block_Widget_Tab_Interface 27 | { 28 | 29 | /** 30 | * Returns the default helper instance. 31 | * 32 | * @return TechDivision_SystemConfigDiff_Helper_Data 33 | * The helper instance 34 | */ 35 | public function defaultHelper() 36 | { 37 | return Mage::helper('techdivision_systemconfigdiff'); 38 | } 39 | 40 | /** 41 | * Can show tab in tabs 42 | * 43 | * @return boolean 44 | */ 45 | public function canShowTab() 46 | { 47 | return true; 48 | } 49 | 50 | /** 51 | * Tab is hidden 52 | * 53 | * @return boolean 54 | */ 55 | public function isHidden() 56 | { 57 | return false; 58 | } 59 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs/Block.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs_Block extends Mage_Adminhtml_Block_Widget_Grid 25 | { 26 | /** 27 | * Set grid params 28 | * 29 | */ 30 | public function __construct() 31 | { 32 | parent::__construct(); 33 | $this->setId('blocksGrid'); 34 | $this->setDefaultSort('identifier'); 35 | $this->setUseAjax(true); 36 | $this->setDefaultDir('ASC'); 37 | $this->setSaveParametersInSession(true); 38 | } 39 | 40 | /** 41 | * Prepare collection 42 | * 43 | * @return Mage_Adminhtml_Block_Widget_Grid 44 | */ 45 | protected function _prepareCollection() 46 | { 47 | $collection = Mage::getModel('techdivision_systemconfigdiff/block')->getCollection(); 48 | $this->setCollection($collection); 49 | $this->setDefaultLimit(50); 50 | 51 | return parent::_prepareCollection(); 52 | } 53 | 54 | /** 55 | * Add columns to grid 56 | * 57 | * @return Mage_Adminhtml_Block_Widget_Grid 58 | */ 59 | protected function _prepareColumns() 60 | { 61 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 62 | 63 | $this->addColumn( 64 | 'identifier', 65 | array( 66 | 'header' => $this->defaultHelper()->__('Block identifier'), 67 | 'align' => 'right', 68 | 'width' => '130px', 69 | 'index' => 'identifier', 70 | ) 71 | ); 72 | 73 | $this->addColumn( 74 | 'store_name', 75 | array( 76 | 'header' => $this->defaultHelper()->__('Store name'), 77 | 'align' => 'right', 78 | 'width' => '130px', 79 | 'index' => 'store_name', 80 | ) 81 | ); 82 | 83 | $this->addColumn( 84 | 'system1_content', 85 | array( 86 | 'header' => $configHelper->getDisplaysettingsAliasThis(), 87 | 'align' => 'right', 88 | 'index' => 'system1_content', 89 | ) 90 | ); 91 | 92 | $this->addColumn( 93 | 'system2_content', 94 | array( 95 | 'header' => $configHelper->getDisplaysettingsAliasOther(), 96 | 'align' => 'left', 97 | 'index' => 'system2_content', 98 | ) 99 | ); 100 | 101 | return parent::_prepareColumns(); 102 | } 103 | 104 | /** 105 | * Rerieve grid URL 106 | * 107 | * @return string 108 | */ 109 | public function getGridUrl() 110 | { 111 | return $this->getData('grid_url') 112 | ? $this->getData('grid_url') 113 | : $this->getUrl('*/*/blockGrid', array('_current' => true)); 114 | } 115 | 116 | /** 117 | * Returns the default helper instance. 118 | * 119 | * @return TechDivision_SystemConfigDiff_Helper_Data 120 | * The helper instance 121 | */ 122 | public function defaultHelper() 123 | { 124 | return Mage::helper('techdivision_systemconfigdiff'); 125 | } 126 | 127 | /** 128 | * Can show tab in tabs 129 | * 130 | * @return boolean 131 | */ 132 | public function canShowTab() 133 | { 134 | return true; 135 | } 136 | 137 | /** 138 | * Tab is hidden 139 | * 140 | * @return boolean 141 | */ 142 | public function isHidden() 143 | { 144 | return false; 145 | } 146 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs/Config.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs_Config extends Mage_Adminhtml_Block_Widget_Grid 25 | { 26 | /** 27 | * Set grid params 28 | * 29 | */ 30 | public function __construct() 31 | { 32 | parent::__construct(); 33 | $this->setId('configGrid'); 34 | $this->setDefaultSort('scope_name'); 35 | $this->setUseAjax(true); 36 | $this->setDefaultDir('ASC'); 37 | $this->setSaveParametersInSession(true); 38 | } 39 | 40 | /** 41 | * Prepare collection 42 | * 43 | * @return Mage_Adminhtml_Block_Widget_Grid 44 | */ 45 | protected function _prepareCollection() 46 | { 47 | $collection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection()->addFieldToFilter('systemXml', '0'); 48 | $this->setCollection($collection); 49 | $this->setDefaultLimit(50); 50 | 51 | return parent::_prepareCollection(); 52 | } 53 | 54 | /** 55 | * Add columns to grid 56 | * 57 | * @return Mage_Adminhtml_Block_Widget_Grid 58 | */ 59 | protected function _prepareColumns() 60 | { 61 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 62 | 63 | $this->addColumn( 64 | 'scope_name', 65 | array( 66 | 'header' => $this->defaultHelper()->__('Scope name'), 67 | 'align' => 'right', 68 | 'width' => '130px', 69 | 'index' => 'scope_name', 70 | ) 71 | ); 72 | 73 | $this->addColumn( 74 | 'path', 75 | array( 76 | 'header' => $this->defaultHelper()->__('Config path'), 77 | 'align' => 'right', 78 | 'width' => '270px', 79 | 'index' => 'path', 80 | ) 81 | ); 82 | 83 | $this->addColumn( 84 | 'system1_value', 85 | array( 86 | 'header' => $configHelper->getDisplaysettingsAliasThis(), 87 | 'align' => 'right', 88 | 'index' => 'system1_value', 89 | ) 90 | ); 91 | 92 | $this->addColumn( 93 | 'system2_value', 94 | array( 95 | 'header' => $configHelper->getDisplaysettingsAliasOther(), 96 | 'align' => 'left', 97 | 'index' => 'system2_value', 98 | ) 99 | ); 100 | 101 | return parent::_prepareColumns(); 102 | } 103 | 104 | /** 105 | * Rerieve grid URL 106 | * 107 | * @return string 108 | */ 109 | public function getGridUrl() 110 | { 111 | return $this->getData('grid_url') 112 | ? $this->getData('grid_url') 113 | : $this->getUrl('*/*/configGrid', array('_current' => true)); 114 | } 115 | 116 | /** 117 | * Returns the default helper instance. 118 | * 119 | * @return TechDivision_SystemConfigDiff_Helper_Data 120 | * The helper instance 121 | */ 122 | public function defaultHelper() 123 | { 124 | return Mage::helper('techdivision_systemconfigdiff'); 125 | } 126 | 127 | /** 128 | * Can show tab in tabs 129 | * 130 | * @return boolean 131 | */ 132 | public function canShowTab() 133 | { 134 | return true; 135 | } 136 | 137 | /** 138 | * Tab is hidden 139 | * 140 | * @return boolean 141 | */ 142 | public function isHidden() 143 | { 144 | return false; 145 | } 146 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs/Page.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs_Page extends Mage_Adminhtml_Block_Widget_Grid 25 | { 26 | /** 27 | * Set grid params 28 | * 29 | */ 30 | public function __construct() 31 | { 32 | parent::__construct(); 33 | $this->setId('pagesGrid'); 34 | $this->setDefaultSort('identifier'); 35 | $this->setUseAjax(true); 36 | $this->setDefaultDir('ASC'); 37 | $this->setSaveParametersInSession(true); 38 | } 39 | 40 | /** 41 | * Prepare collection 42 | * 43 | * @return Mage_Adminhtml_Block_Widget_Grid 44 | */ 45 | protected function _prepareCollection() 46 | { 47 | $collection = Mage::getModel('techdivision_systemconfigdiff/page')->getCollection(); 48 | $this->setCollection($collection); 49 | $this->setDefaultLimit(50); 50 | 51 | return parent::_prepareCollection(); 52 | } 53 | 54 | /** 55 | * Add columns to grid 56 | * 57 | * @return Mage_Adminhtml_Block_Widget_Grid 58 | */ 59 | protected function _prepareColumns() 60 | { 61 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 62 | 63 | $this->addColumn( 64 | 'identifier', 65 | array( 66 | 'header' => $this->defaultHelper()->__('Page identifier'), 67 | 'align' => 'right', 68 | 'width' => '130px', 69 | 'index' => 'identifier', 70 | ) 71 | ); 72 | 73 | $this->addColumn( 74 | 'store_name', 75 | array( 76 | 'header' => $this->defaultHelper()->__('Store name'), 77 | 'align' => 'right', 78 | 'width' => '130px', 79 | 'index' => 'store_name', 80 | ) 81 | ); 82 | 83 | $this->addColumn( 84 | 'system1_content', 85 | array( 86 | 'header' => $configHelper->getDisplaysettingsAliasThis(), 87 | 'align' => 'right', 88 | 'index' => 'system1_content', 89 | ) 90 | ); 91 | 92 | $this->addColumn( 93 | 'system2_content', 94 | array( 95 | 'header' => $configHelper->getDisplaysettingsAliasOther(), 96 | 'align' => 'left', 97 | 'index' => 'system2_content', 98 | ) 99 | ); 100 | 101 | return parent::_prepareColumns(); 102 | } 103 | 104 | /** 105 | * Rerieve grid URL 106 | * 107 | * @return string 108 | */ 109 | public function getGridUrl() 110 | { 111 | return $this->getData('grid_url') 112 | ? $this->getData('grid_url') 113 | : $this->getUrl('*/*/pageGrid', array('_current' => true)); 114 | } 115 | 116 | /** 117 | * Returns the default helper instance. 118 | * 119 | * @return TechDivision_SystemConfigDiff_Helper_Data 120 | * The helper instance 121 | */ 122 | public function defaultHelper() 123 | { 124 | return Mage::helper('techdivision_systemconfigdiff'); 125 | } 126 | 127 | /** 128 | * Can show tab in tabs 129 | * 130 | * @return boolean 131 | */ 132 | public function canShowTab() 133 | { 134 | return true; 135 | } 136 | 137 | /** 138 | * Tab is hidden 139 | * 140 | * @return boolean 141 | */ 142 | public function isHidden() 143 | { 144 | return false; 145 | } 146 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/Overview/Tabs/SystemConfig.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_Overview_Tabs_SystemConfig extends Mage_Adminhtml_Block_Widget_Grid 25 | { 26 | /** 27 | * Set grid params 28 | * 29 | */ 30 | public function __construct() 31 | { 32 | parent::__construct(); 33 | $this->setId('systemConfigGrid'); 34 | $this->setDefaultSort('scope_name'); 35 | $this->setUseAjax(true); 36 | $this->setDefaultDir('ASC'); 37 | $this->setSaveParametersInSession(true); 38 | } 39 | 40 | /** 41 | * Prepare collection 42 | * 43 | * @return Mage_Adminhtml_Block_Widget_Grid 44 | */ 45 | protected function _prepareCollection() 46 | { 47 | $collection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection()->addFieldToFilter('systemXml', '1'); 48 | $this->setCollection($collection); 49 | $this->setDefaultLimit(50); 50 | 51 | return parent::_prepareCollection(); 52 | } 53 | 54 | /** 55 | * Add columns to grid 56 | * 57 | * @return Mage_Adminhtml_Block_Widget_Grid 58 | */ 59 | protected function _prepareColumns() 60 | { 61 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 62 | 63 | $this->addColumn( 64 | 'scope_name', 65 | array( 66 | 'header' => $this->defaultHelper()->__('Scope name'), 67 | 'align' => 'right', 68 | 'width' => '130px', 69 | 'index' => 'scope_name', 70 | ) 71 | ); 72 | 73 | $this->addColumn( 74 | 'path', 75 | array( 76 | 'header' => $this->defaultHelper()->__('Config path'), 77 | 'align' => 'right', 78 | 'width' => '270px', 79 | 'index' => 'path', 80 | ) 81 | ); 82 | 83 | $this->addColumn( 84 | 'system1_value', 85 | array( 86 | 'header' => $configHelper->getDisplaysettingsAliasThis(), 87 | 'align' => 'right', 88 | 'index' => 'system1_value', 89 | ) 90 | ); 91 | 92 | $this->addColumn( 93 | 'system2_value', 94 | array( 95 | 'header' => $configHelper->getDisplaysettingsAliasOther(), 96 | 'align' => 'left', 97 | 'index' => 'system2_value', 98 | ) 99 | ); 100 | 101 | return parent::_prepareColumns(); 102 | } 103 | 104 | /** 105 | * Rerieve grid URL 106 | * 107 | * @return string 108 | */ 109 | public function getGridUrl() 110 | { 111 | return $this->getData('grid_url') 112 | ? $this->getData('grid_url') 113 | : $this->getUrl('*/*/systemGrid', array('_current' => true)); 114 | } 115 | 116 | /** 117 | * Returns the default helper instance. 118 | * 119 | * @return TechDivision_SystemConfigDiff_Helper_Data 120 | * The helper instance 121 | */ 122 | public function defaultHelper() 123 | { 124 | return Mage::helper('techdivision_systemconfigdiff'); 125 | } 126 | 127 | /** 128 | * Can show tab in tabs 129 | * 130 | * @return boolean 131 | */ 132 | public function canShowTab() 133 | { 134 | return true; 135 | } 136 | 137 | /** 138 | * Tab is hidden 139 | * 140 | * @return boolean 141 | */ 142 | public function isHidden() 143 | { 144 | return false; 145 | } 146 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/System/Config/Form/Field.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field 25 | extends Mage_Adminhtml_Block_System_Config_Form_Field 26 | { 27 | /** 28 | * The render method is copied from the core block. Only only one line at the end of this method is added. 29 | * This method has to be made backwards compatible. Versions lower 1.12.0.1 have different code in this function. 30 | * 31 | * @param Varien_Data_Form_Element_Abstract $element The field element to be rendered 32 | * @return string Html of field 33 | */ 34 | public function render(Varien_Data_Form_Element_Abstract $element) 35 | { 36 | $id = $element->getHtmlId(); 37 | 38 | if(version_compare(Mage::getVersion(), '1.12.0.1') >= 0){ 39 | $html = ''; 40 | } else { 41 | $useContainerId = $element->getData('use_container_id'); 42 | $html = '' 43 | . ''; 44 | } 45 | 46 | //$isDefault = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store'); 47 | $isMultiple = $element->getExtType()==='multiple'; 48 | 49 | // replace [value] with [inherit] 50 | $namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName()); 51 | 52 | $options = $element->getValues(); 53 | 54 | $addInheritCheckbox = false; 55 | if ($element->getCanUseWebsiteValue()) { 56 | $addInheritCheckbox = true; 57 | $checkboxLabel = Mage::helper('adminhtml')->__('Use Website'); 58 | } 59 | elseif ($element->getCanUseDefaultValue()) { 60 | $addInheritCheckbox = true; 61 | $checkboxLabel = Mage::helper('adminhtml')->__('Use Default'); 62 | } 63 | 64 | if ($addInheritCheckbox) { 65 | $inherit = $element->getInherit()==1 ? 'checked="checked"' : ''; 66 | if ($inherit) { 67 | $element->setDisabled(true); 68 | } 69 | } 70 | 71 | if(version_compare(Mage::getVersion(), '1.12.0.1') >= 0){ 72 | if ($element->getTooltip()) { 73 | $html .= ''; 74 | $html .= $this->_getElementHtml($element); 75 | $html .= '
' . $element->getTooltip() . '
'; 76 | } else { 77 | $html .= ''; 78 | $html .= $this->_getElementHtml($element); 79 | }; 80 | } else { 81 | $html .= ''; 82 | $html .= $this->_getElementHtml($element); 83 | } 84 | 85 | if ($element->getComment()) { 86 | $html.= '

'.$element->getComment().'

'; 87 | } 88 | $html.= ''; 89 | 90 | if ($addInheritCheckbox) { 91 | 92 | $defText = $element->getDefaultValue(); 93 | if ($options) { 94 | $defTextArr = array(); 95 | foreach ($options as $k=>$v) { 96 | if ($isMultiple) { 97 | if (is_array($v['value']) && in_array($k, $v['value'])) { 98 | $defTextArr[] = $v['label']; 99 | } 100 | } elseif ($v['value']==$defText) { 101 | $defTextArr[] = $v['label']; 102 | break; 103 | } 104 | } 105 | $defText = join(', ', $defTextArr); 106 | } 107 | 108 | // default value 109 | $html.= ''; 110 | //$html.= ''; 111 | $html.= ' '; 112 | $html.= ''; 113 | $html.= ''; 114 | } 115 | 116 | $html.= ''; 117 | if ($element->getScope()) { 118 | $html .= $element->getScopeLabel(); 119 | } 120 | $html.= ''; 121 | 122 | // The only line which is added to this core method 123 | $html .= $this->_addDiffErrorHtml($element); 124 | 125 | $html.= ''; 126 | if ($element->getHint()) { 127 | $html.= '
'; 128 | $html.= '
' . $element->getHint() . '
'; 129 | $html.= '
'; 130 | } 131 | $html.= ''; 132 | 133 | if(version_compare(Mage::getVersion(), '1.12.0.1') >= 0){ 134 | return $this->_decorateRowHtml($element, $html); 135 | } else { 136 | $html.= ''; 137 | return $html; 138 | } 139 | } 140 | 141 | /** 142 | * Adds the html for the diff error for a specific element 143 | * 144 | * @param $element The current element to render 145 | * @return string 146 | */ 147 | protected function _addDiffErrorHtml($element) 148 | { 149 | $html = ''; 150 | 151 | // If diff is not displayed in system config return empty html 152 | if(!Mage::helper('techdivision_systemconfigdiff/config')->getDisplaysettingsShowDiff()){ 153 | return $html; 154 | } 155 | 156 | $collection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection(); 157 | 158 | // Get path and scope 159 | $path = $this->_getPathByName($element->getData('name')); 160 | $scope = $element->getData('scope'); 161 | 162 | // Check if we should ignore this path for displaying 163 | if(in_array($path, Mage::helper('techdivision_systemconfigdiff')->getIgnorePaths())){ 164 | return $html; 165 | } 166 | 167 | // Filter collection by current path and scope 168 | $collection->addFieldToFilter('path', $path); 169 | $collection->addFieldToFilter('scope', $scope); 170 | 171 | // If not default scope add filter to the collection 172 | if($scope !== 'default'){ 173 | $collection->addFieldToFilter('scope_id', $element->getScopeId()); 174 | 175 | // Get current website/store code 176 | $configData = Mage::getSingleton('adminhtml/config_data'); 177 | $website = $configData->getWebsite(); 178 | $store = $configData->getStore(); 179 | 180 | if($store === ''){ 181 | // Website 182 | $collection->addFieldToFilter('code', $website); 183 | } else { 184 | // Store 185 | $collection->addFieldToFilter('code', $store); 186 | } 187 | } 188 | 189 | // If an entry was found and has data add the diff error html 190 | $entry = $collection->getFirstItem(); 191 | if(count($entry->getData()) > 0){ 192 | $buttonTitle = Mage::helper('techdivision_systemconfigdiff')->__('Replace config'); 193 | $html .= ''; 194 | $html .= ''; 197 | $html .= ''; 198 | $html .= ''; 199 | $html .= '
'; 200 | $html .= $this->_getDiffElementHtml($element, $entry->getSystem2Value()); 201 | $html .= '
'; 202 | $html .= '
'; 203 | $html .= '
'; 204 | $html .= $path; 205 | $html .= '
'; 206 | $html .= '
'; 207 | $html .= $scope; 208 | $html .= '
'; 209 | $html .= '
'; 210 | $html .= $element->getScopeId(); 211 | $html .= '
'; 212 | $html .= '
'; 213 | $html .= Mage::helper('adminhtml')->getUrl('techdivision_systemconfigdiff/adminhtml_index/update'); 214 | $html .= '
'; 215 | $html .= '
'; 216 | $html .= ''; 217 | } 218 | 219 | return $html; 220 | } 221 | 222 | /** 223 | * The only way to get the path is by the name of the element (i.e. groups[unsecure][fields][base_media_url][value]) 224 | * Magento does not provide the path at this point 225 | * 226 | * @param $name 227 | * @return string 228 | */ 229 | protected function _getPathByName($name){ 230 | $path = ''; 231 | $name = explode("[", $name); 232 | 233 | $path .= $this->getRequest()->getParam('section'); 234 | $path .= '/' . substr_replace($name[1] ,"",-1); 235 | $path .= '/' . substr_replace($name[3] ,"",-1); 236 | 237 | return $path; 238 | } 239 | 240 | /** 241 | * Returns the element html rendered with the config value of the other system 242 | * Also deletes the id and name attribute 243 | * 244 | * @param Varien_Data_Form_Element_Abstract $element 245 | * @return string 246 | */ 247 | protected function _getDiffElementHtml(Varien_Data_Form_Element_Abstract $element, $value) 248 | { 249 | if($element->getRenderer() instanceof TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field_Regexceptions){ 250 | $value = unserialize($value); 251 | } 252 | // Set the value of the other system 253 | $element->setValue($value); 254 | 255 | // Get the rendered html 256 | $html = $this->_getElementHtml($element); 257 | 258 | // Adapt html 259 | $doc = new DOMDocument(); 260 | $doc->loadHTML(utf8_decode($html)); 261 | 262 | // Remove !DOCTYPE tag 263 | $doc->removeChild($doc->firstChild); 264 | 265 | /* @var DOMNode $node */ 266 | 267 | // Throw away the id and name attribute of the field html 268 | // to avoid changes made in this form field get saved on submit button click 269 | foreach($doc->getElementsByTagName('input') as $node){ 270 | if($node->hasAttribute('type') && $node->getAttribute('type') === 'hidden'){ 271 | $node->parentNode->removeChild($node); 272 | continue; 273 | } 274 | 275 | $node->removeAttribute('id'); 276 | $node->removeAttribute('name'); 277 | } 278 | 279 | foreach($doc->getElementsByTagName('select') as $node){ 280 | $node->removeAttribute('id'); 281 | $node->removeAttribute('name'); 282 | } 283 | 284 | foreach($doc->getElementsByTagName('textarea') as $node){ 285 | $node->removeAttribute('id'); 286 | $node->removeAttribute('name'); 287 | } 288 | 289 | // Get all script nodes as string to adapt them 290 | $script = ''; 291 | foreach($doc->getElementsByTagName('script') as $node){ 292 | $script .= $doc->saveHtml($node); 293 | $node->parentNode->removeChild($node); 294 | } 295 | 296 | // Remove all id and name attributes inside the script 297 | $script = preg_replace('/id\="[^"]*"/', '', $script); 298 | $script = preg_replace('/name\="[^"]*"/', '', $script); 299 | 300 | // Add the script at the end of the html 301 | $html = utf8_encode($doc->saveHTML()) . $script; 302 | 303 | // Throw away html and body tags 304 | $html = str_replace(array('', '', '', ''), array('', '', '', ''), $html); 305 | 306 | return $html; 307 | } 308 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/System/Config/Form/Field/Array/Abstract.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | abstract class TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field_Array_Abstract 25 | extends TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field 26 | { 27 | /** 28 | * Grid columns 29 | * 30 | * @var array 31 | */ 32 | protected $_columns = array(); 33 | 34 | /** 35 | * Enable the "Add after" button or not 36 | * 37 | * @var bool 38 | */ 39 | protected $_addAfter = true; 40 | 41 | /** 42 | * Label of add button 43 | * 44 | * @var unknown_type 45 | */ 46 | protected $_addButtonLabel; 47 | 48 | /** 49 | * Rows cache 50 | * 51 | * @var array|null 52 | */ 53 | private $_arrayRowsCache; 54 | 55 | /** 56 | * Indication whether block is prepared to render or no 57 | * 58 | * @var bool 59 | */ 60 | protected $_isPreparedToRender = false; 61 | 62 | /** 63 | * Check if columns are defined, set template 64 | * 65 | */ 66 | public function __construct() 67 | { 68 | if (!$this->_addButtonLabel) { 69 | $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add'); 70 | } 71 | parent::__construct(); 72 | if (!$this->getTemplate()) { 73 | $this->setTemplate('system/config/form/field/array.phtml'); 74 | } 75 | } 76 | 77 | /** 78 | * Add a column to array-grid 79 | * 80 | * @param string $name 81 | * @param array $params 82 | */ 83 | public function addColumn($name, $params) 84 | { 85 | $this->_columns[$name] = array( 86 | 'label' => empty($params['label']) ? 'Column' : $params['label'], 87 | 'size' => empty($params['size']) ? false : $params['size'], 88 | 'style' => empty($params['style']) ? null : $params['style'], 89 | 'class' => empty($params['class']) ? null : $params['class'], 90 | 'renderer' => false, 91 | ); 92 | if ((!empty($params['renderer'])) && ($params['renderer'] instanceof Mage_Core_Block_Abstract)) { 93 | $this->_columns[$name]['renderer'] = $params['renderer']; 94 | } 95 | } 96 | 97 | /** 98 | * Get the grid and scripts contents 99 | * 100 | * @param Varien_Data_Form_Element_Abstract $element 101 | * @return string 102 | */ 103 | protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) 104 | { 105 | $this->setElement($element); 106 | $html = $this->_toHtml(); 107 | $this->_arrayRowsCache = null; // doh, the object is used as singleton! 108 | return $html; 109 | } 110 | 111 | /** 112 | * Prepare existing row data object 113 | * 114 | * @param Varien_Object 115 | */ 116 | protected function _prepareArrayRow(Varien_Object $row) 117 | { 118 | // override in descendants 119 | } 120 | 121 | /** 122 | * Obtain existing data from form element 123 | * 124 | * Each row will be instance of Varien_Object 125 | * 126 | * @return array 127 | */ 128 | public function getArrayRows() 129 | { 130 | if (null !== $this->_arrayRowsCache) { 131 | return $this->_arrayRowsCache; 132 | } 133 | $result = array(); 134 | /** @var Varien_Data_Form_Element_Abstract */ 135 | $element = $this->getElement(); 136 | if ($element->getValue() && is_array($element->getValue())) { 137 | foreach ($element->getValue() as $rowId => $row) { 138 | foreach ($row as $key => $value) { 139 | $row[$key] = $this->htmlEscape($value); 140 | } 141 | $row['_id'] = $rowId; 142 | $result[$rowId] = new Varien_Object($row); 143 | $this->_prepareArrayRow($result[$rowId]); 144 | } 145 | } 146 | $this->_arrayRowsCache = $result; 147 | return $this->_arrayRowsCache; 148 | } 149 | 150 | /** 151 | * Render array cell for prototypeJS template 152 | * 153 | * @param string $columnName 154 | * @return string 155 | */ 156 | protected function _renderCellTemplate($columnName) 157 | { 158 | if (empty($this->_columns[$columnName])) { 159 | throw new Exception('Wrong column name specified.'); 160 | } 161 | $column = $this->_columns[$columnName]; 162 | $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']'; 163 | 164 | if ($column['renderer']) { 165 | return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column) 166 | ->toHtml(); 167 | } 168 | 169 | return ''; 173 | } 174 | 175 | /** 176 | * Prepare to render 177 | */ 178 | protected function _prepareToRender() 179 | { 180 | // Override in descendants to add columns, change add button label etc 181 | } 182 | 183 | /** 184 | * Render block HTML 185 | * 186 | * @return string 187 | */ 188 | protected function _toHtml() 189 | { 190 | if (!$this->_isPreparedToRender) { 191 | $this->_prepareToRender(); 192 | $this->_isPreparedToRender = true; 193 | } 194 | if (empty($this->_columns)) { 195 | throw new Exception('At least one column must be defined.'); 196 | } 197 | return parent::_toHtml(); 198 | } 199 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Block/Adminhtml/System/Config/Form/Field/Regexceptions.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field_Regexceptions 26 | extends TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field_Array_Abstract 27 | { 28 | public function __construct() 29 | { 30 | $this->addColumn('regexp', array( 31 | 'label' => Mage::helper('adminhtml')->__('Matched Expression'), 32 | 'style' => 'width:120px', 33 | )); 34 | $this->addColumn('value', array( 35 | 'label' => Mage::helper('adminhtml')->__('Value'), 36 | 'style' => 'width:120px', 37 | )); 38 | $this->_addAfter = false; 39 | $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add Exception'); 40 | parent::__construct(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Helper/Config.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Helper_Config 25 | extends TechDivision_SystemConfigDiff_Helper_Config_Abstract 26 | { 27 | /** 28 | * The module alias of this module 29 | */ 30 | const MODULE_ALIAS = "techdivision_systemconfigdiff"; 31 | 32 | /** 33 | * The registered differs 34 | * @var array 35 | */ 36 | protected $_differs; 37 | 38 | /** 39 | * Returns the differs defined in config.xml 40 | * 41 | * @return array The differs 42 | */ 43 | public function getDiffers() 44 | { 45 | // Check if differs are initiated already. 46 | if (!$this->_differs) { 47 | $this->_differs = array(); 48 | 49 | /** @var Mage_Core_Model_Config $config */ 50 | $config = Mage::app()->getConfig(); 51 | 52 | // Get all differs defined in config.xml 53 | $differConfig = $config->getNode('global')->differs; 54 | 55 | // Iterate over all differ configs 56 | foreach ($differConfig->children() as $name => $config) { 57 | // Try to initialize the differs 58 | try { 59 | // Get model class name 60 | $modelClassName = (string) $config->class; 61 | // Initialize a new differ instance 62 | $this->_differs[$name] = Mage::getModel($modelClassName); 63 | } 64 | catch (Exception $e) { 65 | Mage::log($e->getMessage()); 66 | Mage::throwException('Can not initialize differ "%s".', $modelClassName); 67 | } 68 | } 69 | } 70 | 71 | // Return differs 72 | return $this->_differs; 73 | } 74 | 75 | /** 76 | * Returns the module alias of this module 77 | * 78 | * @return string 79 | */ 80 | public function getModuleAlias() 81 | { 82 | return self::MODULE_ALIAS; 83 | } 84 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Helper/Config/Abstract.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | abstract class TechDivision_SystemConfigDiff_Helper_Config_Abstract 25 | extends Mage_Core_Helper_Abstract 26 | { 27 | /** 28 | * Holds the xml path to the config value 29 | * techdivision_systemconfigdiff/systemsettings/system_url . 30 | * 31 | * @var string 32 | */ 33 | const XML_PATH_SYSTEMSETTINGS_SYSTEM_URL 34 | = 'techdivision_systemconfigdiff/systemsettings/system_url'; 35 | 36 | 37 | /** 38 | * Holds the xml path to the config value 39 | * techdivision_systemconfigdiff/systemsettings/user . 40 | * 41 | * @var string 42 | */ 43 | const XML_PATH_SYSTEMSETTINGS_USER 44 | = 'techdivision_systemconfigdiff/systemsettings/user'; 45 | 46 | 47 | /** 48 | * Holds the xml path to the config value 49 | * techdivision_systemconfigdiff/systemsettings/password . 50 | * 51 | * @var string 52 | */ 53 | const XML_PATH_SYSTEMSETTINGS_PASSWORD 54 | = 'techdivision_systemconfigdiff/systemsettings/password'; 55 | 56 | 57 | /** 58 | * Holds the xml path to the config value 59 | * techdivision_systemconfigdiff/systemsettings/wsi . 60 | * 61 | * @var string 62 | */ 63 | const XML_PATH_SYSTEMSETTINGS_WSI 64 | = 'techdivision_systemconfigdiff/systemsettings/wsi'; 65 | 66 | 67 | /** 68 | * Holds the xml path to the config value 69 | * techdivision_systemconfigdiff/systemsettings/cron_enabled . 70 | * 71 | * @var string 72 | */ 73 | const XML_PATH_SYSTEMSETTINGS_CRON_ENABLED 74 | = 'techdivision_systemconfigdiff/systemsettings/cron_enabled'; 75 | 76 | 77 | /** 78 | * Holds the xml path to the config value 79 | * techdivision_systemconfigdiff/systemsettings/cron . 80 | * 81 | * @var string 82 | */ 83 | const XML_PATH_SYSTEMSETTINGS_CRON 84 | = 'techdivision_systemconfigdiff/systemsettings/cron'; 85 | 86 | 87 | /** 88 | * Holds the xml path to the config value 89 | * techdivision_systemconfigdiff/systemsettings/base_url_replace_enabled . 90 | * 91 | * @var string 92 | */ 93 | const XML_PATH_SYSTEMSETTINGS_BASE_URL_REPLACE_ENABLED 94 | = 'techdivision_systemconfigdiff/systemsettings/base_url_replace_enabled'; 95 | 96 | 97 | /** 98 | * Holds the xml path to the config value 99 | * techdivision_systemconfigdiff/displaysettings/alias_this . 100 | * 101 | * @var string 102 | */ 103 | const XML_PATH_DISPLAYSETTINGS_ALIAS_THIS 104 | = 'techdivision_systemconfigdiff/displaysettings/alias_this'; 105 | 106 | 107 | /** 108 | * Holds the xml path to the config value 109 | * techdivision_systemconfigdiff/displaysettings/alias_other . 110 | * 111 | * @var string 112 | */ 113 | const XML_PATH_DISPLAYSETTINGS_ALIAS_OTHER 114 | = 'techdivision_systemconfigdiff/displaysettings/alias_other'; 115 | 116 | 117 | /** 118 | * Holds the xml path to the config value 119 | * techdivision_systemconfigdiff/displaysettings/show_diff . 120 | * 121 | * @var string 122 | */ 123 | const XML_PATH_DISPLAYSETTINGS_SHOW_DIFF 124 | = 'techdivision_systemconfigdiff/displaysettings/show_diff'; 125 | 126 | 127 | /** 128 | * Holds the xml path to the config value 129 | * techdivision_systemconfigdiff/displaysettings/ignore_paths . 130 | * 131 | * @var string 132 | */ 133 | const XML_PATH_DISPLAYSETTINGS_IGNORE_PATHS 134 | = 'techdivision_systemconfigdiff/displaysettings/ignore_paths'; 135 | 136 | 137 | 138 | /** 139 | * Returns the configured value for the config value 140 | * techdivision_systemconfigdiff/systemsettings/system_url . 141 | * 142 | * @param void 143 | * @return mixed 144 | */ 145 | public function getSystemsettingsSystemUrl($storeId = null) { 146 | $config = Mage::getStoreConfig( 147 | self::XML_PATH_SYSTEMSETTINGS_SYSTEM_URL , $storeId 148 | ); 149 | 150 | return $config; 151 | } 152 | 153 | /** 154 | * Returns the configured value for the config value 155 | * techdivision_systemconfigdiff/systemsettings/user . 156 | * 157 | * @param void 158 | * @return mixed 159 | */ 160 | public function getSystemsettingsUser($storeId = null) { 161 | $config = Mage::getStoreConfig( 162 | self::XML_PATH_SYSTEMSETTINGS_USER , $storeId 163 | ); 164 | 165 | return $config; 166 | } 167 | 168 | /** 169 | * Returns the configured value for the config value 170 | * techdivision_systemconfigdiff/systemsettings/password . 171 | * 172 | * @param void 173 | * @return mixed 174 | */ 175 | public function getSystemsettingsPassword($storeId = null) { 176 | $config = Mage::getStoreConfig( 177 | self::XML_PATH_SYSTEMSETTINGS_PASSWORD , $storeId 178 | ); 179 | 180 | return $config; 181 | } 182 | 183 | /** 184 | * Returns the configured value for the config value 185 | * techdivision_systemconfigdiff/systemsettings/wsi . 186 | * 187 | * @param void 188 | * @return mixed 189 | */ 190 | public function getSystemsettingsWsi($storeId = null) { 191 | $config = Mage::getStoreConfig( 192 | self::XML_PATH_SYSTEMSETTINGS_WSI , $storeId 193 | ); 194 | 195 | return $config; 196 | } 197 | 198 | /** 199 | * Returns the configured value for the config value 200 | * techdivision_systemconfigdiff/systemsettings/cron_enabled . 201 | * 202 | * @param void 203 | * @return mixed 204 | */ 205 | public function getSystemsettingsCronEnabled($storeId = null) { 206 | $config = Mage::getStoreConfig( 207 | self::XML_PATH_SYSTEMSETTINGS_CRON_ENABLED , $storeId 208 | ); 209 | 210 | return $config; 211 | } 212 | 213 | /** 214 | * Returns the configured value for the config value 215 | * techdivision_systemconfigdiff/systemsettings/cron . 216 | * 217 | * @param void 218 | * @return mixed 219 | */ 220 | public function getSystemsettingsCron($storeId = null) { 221 | $config = Mage::getStoreConfig( 222 | self::XML_PATH_SYSTEMSETTINGS_CRON , $storeId 223 | ); 224 | 225 | return $config; 226 | } 227 | 228 | /** 229 | * Returns the configured value for the config value 230 | * techdivision_systemconfigdiff/systemsettings/base_url_replace_enabled . 231 | * 232 | * @param void 233 | * @return mixed 234 | */ 235 | public function getSystemsettingsBaseUrlReplaceEnabled($storeId = null) { 236 | $config = Mage::getStoreConfig( 237 | self::XML_PATH_SYSTEMSETTINGS_BASE_URL_REPLACE_ENABLED , $storeId 238 | ); 239 | 240 | return $config; 241 | } 242 | 243 | /** 244 | * Returns the configured value for the config value 245 | * techdivision_systemconfigdiff/displaysettings/alias_this . 246 | * 247 | * @param void 248 | * @return mixed 249 | */ 250 | public function getDisplaysettingsAliasThis($storeId = null) { 251 | $config = Mage::getStoreConfig( 252 | self::XML_PATH_DISPLAYSETTINGS_ALIAS_THIS , $storeId 253 | ); 254 | 255 | return $config; 256 | } 257 | 258 | /** 259 | * Returns the configured value for the config value 260 | * techdivision_systemconfigdiff/displaysettings/alias_other . 261 | * 262 | * @param void 263 | * @return mixed 264 | */ 265 | public function getDisplaysettingsAliasOther($storeId = null) { 266 | $config = Mage::getStoreConfig( 267 | self::XML_PATH_DISPLAYSETTINGS_ALIAS_OTHER , $storeId 268 | ); 269 | 270 | return $config; 271 | } 272 | 273 | /** 274 | * Returns the configured value for the config value 275 | * techdivision_systemconfigdiff/displaysettings/show_diff . 276 | * 277 | * @param void 278 | * @return mixed 279 | */ 280 | public function getDisplaysettingsShowDiff($storeId = null) { 281 | $config = Mage::getStoreConfig( 282 | self::XML_PATH_DISPLAYSETTINGS_SHOW_DIFF , $storeId 283 | ); 284 | 285 | return $config; 286 | } 287 | 288 | /** 289 | * Returns the configured value for the config value 290 | * techdivision_systemconfigdiff/displaysettings/ignore_paths . 291 | * 292 | * @param void 293 | * @return array 294 | */ 295 | public function getDisplaysettingsIgnorePaths($storeId = null) { 296 | $config = Mage::getStoreConfig( 297 | self::XML_PATH_DISPLAYSETTINGS_IGNORE_PATHS , $storeId 298 | ); 299 | 300 | $config = explode(",", $config); 301 | 302 | 303 | return $config; 304 | } 305 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Helper/Data.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Helper_Data 25 | extends Mage_Core_Helper_Abstract 26 | { 27 | /** 28 | * @var The ignore paths configured in backend 29 | */ 30 | protected $_ignorePaths; 31 | 32 | public function getIgnorePaths(){ 33 | if(!$this->_ignorePaths){ 34 | /* @var TechDivision_SystemConfigDiff_Helper_Config $configHelper */ 35 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 36 | 37 | $this->_ignorePaths = $configHelper->getDisplaysettingsIgnorePaths(); 38 | } 39 | 40 | return $this->_ignorePaths; 41 | } 42 | 43 | /** 44 | * Returns all ids of the sections which have a diff error. 45 | * Called by tabs.phtml 46 | * 47 | * @return array 48 | */ 49 | public function getSectionIds() 50 | { 51 | $sectionIds = array(); 52 | $collection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection()->addFieldtoFilter('systemXml', '1'); 53 | 54 | // Get actual website and store code 55 | $configData = Mage::getSingleton('adminhtml/config_data'); 56 | $website = $configData->getWebsite(); 57 | $store = $configData->getStore(); 58 | 59 | // Filter collection 60 | if($website !== '' && $store === ''){ 61 | // Website scope 62 | $collection->addFieldToFilter('scope', 'websites'); 63 | $collection->addFieldToFilter('code', $website); 64 | } else if($website !== '' && $store !== ''){ 65 | // Store scope 66 | $collection->addFieldToFilter('scope', 'stores'); 67 | $collection->addFieldToFilter('code', $store); 68 | } else { 69 | // Default scope 70 | $collection->addFieldToFilter('scope', 'default'); 71 | } 72 | 73 | // Get the path for every entry and add the section part of it to the result array 74 | foreach($collection as $entry){ 75 | $path = $entry->getPath(); 76 | 77 | // Check if we should ignore this path for displaying 78 | if(in_array($path, $this->getIgnorePaths())) continue; 79 | 80 | $pathExpl = explode('/', $path, 2); 81 | if(!in_array($pathExpl[0], $sectionIds)){ 82 | $sectionIds[] = $pathExpl[0]; 83 | } 84 | } 85 | 86 | return $sectionIds; 87 | } 88 | 89 | /** 90 | * Returns all scope codes which have a diff error. 91 | * Called by switcher.phtml 92 | * 93 | * @return array 94 | */ 95 | public function getValues() 96 | { 97 | $values = array(); 98 | $collection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection()->addFieldtoFilter('systemXml', '1'); 99 | 100 | // Get the scope for every entry 101 | foreach($collection as $entry){ 102 | // Check if we should ignore this path for displaying 103 | if(in_array($entry->getPath(), $this->getIgnorePaths())) continue; 104 | 105 | $scope = $entry->getScope(); 106 | 107 | // Add default scope immediately 108 | if($scope === 'default'){ 109 | if(!in_array($scope, $values)){ 110 | $values[] = $scope; 111 | } 112 | continue; 113 | } 114 | 115 | // If not default scope get the scope code 116 | $code = $entry->getCode(); 117 | 118 | // Due to inconsistencies of Magento we have to cut the s of websites/stores 119 | $scope = substr_replace($scope ,"", -1); 120 | 121 | $scope = $scope . '_' . $code; 122 | 123 | // Add scope code 124 | if(!in_array($scope, $values)){ 125 | $values[] = $scope; 126 | } 127 | } 128 | 129 | return $values; 130 | } 131 | 132 | /** 133 | * Returns the inline element css style without background definition. 134 | * Called by switcher.phtml to override the background with diff error image. 135 | * 136 | * @param $style The inline css style of the element 137 | * @return string 138 | */ 139 | public function getElementStyle($style) 140 | { 141 | $styles = explode(';', $style); 142 | $style = array(); 143 | foreach($styles as $_style){ 144 | if(strncmp(trim($_style), 'background', strlen('background'))){ 145 | $style[] = $_style; 146 | } 147 | } 148 | 149 | return implode(';', $style); 150 | } 151 | 152 | /** 153 | * Deletes a diff entry and all inherited config diffs specified by path, scope and scopeId 154 | * 155 | * @param $entry The diff entry to be deleted 156 | * @param $path The config path 157 | * @param $scope Dependent of the scope the inherited config diffs will be deleted 158 | * @param $scopeId Dependent of the scopeId the inherited config diffs will be deleted 159 | */ 160 | public function deleteDiff($entry, $path, $scope, $scopeId) 161 | { 162 | // The value for actual $scope which is the reference value for all underlying scopes 163 | $compareValue = $entry->getSystem1Value(); 164 | 165 | // Delete this entry (for this $scope and $path) 166 | $entry->delete(); 167 | 168 | // For default scope check all websites and stores 169 | if($scope === 'default'){ 170 | // The website ids which have been deleted 171 | $deletedIds = array(); 172 | 173 | // Get all websites scope diffs 174 | $configCollection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection() 175 | ->addFieldToFilter('systemXml', '1') 176 | ->addFieldToFilter('path', $path) 177 | ->addFieldtoFilter('scope', 'websites'); 178 | 179 | // For all found diff entries 180 | foreach($configCollection as $diffEntry){ 181 | // Get the website scope value and compare it with the reference value (default scope) 182 | $websiteValue = $diffEntry->getSystem1Value(); 183 | if($websiteValue === $compareValue){ 184 | // Add the website id to deletedIds array and delete diff entry 185 | $deletedIds[] = $diffEntry->getScopeId(); 186 | $diffEntry->delete(); 187 | } 188 | } 189 | 190 | // Get all stores 191 | $storeCollection = Mage::getModel('core/store')->getCollection(); 192 | // Activate default website/store loading 193 | $storeCollection->setFlag('load_default_store', true); 194 | 195 | // For all stores 196 | foreach($storeCollection as $store){ 197 | // Check if $store belongs to one of the websites which have been deleted before 198 | if(!in_array($store->getWebsiteId(), $deletedIds)){ 199 | continue; 200 | } 201 | 202 | // Get the store scope diff 203 | $configCollection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection() 204 | ->addFieldToFilter('systemXml', '1') 205 | ->addFieldToFilter('path', $path) 206 | ->addFieldtoFilter('scope', 'stores') 207 | ->addFieldToFilter('scope_id', $store->getStoreId()); 208 | 209 | // It can only be one entry 210 | $diffEntry = $configCollection->getFirstItem(); 211 | if(count($diffEntry->getData()) > 0){ 212 | // Get the store scope value and compare it with the reference value (default scope) 213 | $storeValue = $diffEntry->getSystem1Value(); 214 | if($storeValue === $compareValue){ 215 | // Delete diff entry 216 | $diffEntry->delete(); 217 | } 218 | } 219 | } 220 | } else if($scope === 'websites'){ 221 | // For websites scope check stores 222 | 223 | // Get all stores 224 | $storeCollection = Mage::getModel('core/store')->getCollection(); 225 | // Activate default website/store loading 226 | $storeCollection->setFlag('load_default_store', true); 227 | 228 | // For all stores 229 | foreach($storeCollection as $store){ 230 | // Check if $store belongs to the website 231 | if($store->getWebsiteId() !== $scopeId){ 232 | continue; 233 | } 234 | 235 | // Get the store scope diff 236 | $configCollection = Mage::getModel('techdivision_systemconfigdiff/config')->getCollection() 237 | ->addFieldToFilter('systemXml', '1') 238 | ->addFieldToFilter('path', $path) 239 | ->addFieldtoFilter('scope', 'stores') 240 | ->addFieldToFilter('scope_id', $store->getStoreId()); 241 | 242 | // It can only be one entry 243 | $diffEntry = $configCollection->getFirstItem(); 244 | if(count($diffEntry->getData()) > 0){ 245 | // Get the store scope value and compare it with the reference value (default scope) 246 | $storeValue = $diffEntry->getSystem1Value(); 247 | if($storeValue === $compareValue){ 248 | // Delete diff entry 249 | $diffEntry->delete(); 250 | } 251 | } 252 | } 253 | } 254 | } 255 | 256 | /* 257 | * Returns the array of paths defined in all system.xml files 258 | */ 259 | public function getSystemXmlPaths(){ 260 | $systemXmlPaths = array(); 261 | 262 | // Get all sections of system config 263 | $config = Mage::getConfig()->loadModulesConfiguration('system.xml')->applyExtends(); 264 | $configSections = $config->getNode('sections')->asArray(); 265 | 266 | // Iterate over sections/*/groups/*/fields/* axis 267 | foreach($configSections as $key => $sections){ 268 | $sectionName = $key; 269 | foreach($sections['groups'] as $key => $groups){ 270 | $groupName = $key; 271 | if(isset($groups['fields']) && is_array($groups['fields'])){ 272 | foreach($groups['fields'] as $key => $fields){ 273 | $systemXmlPaths[] = $sectionName . '/' . $groupName . '/' . $key; 274 | } 275 | } else { 276 | $systemXmlPaths[] = $sectionName . '/' . $groupName; 277 | } 278 | } 279 | } 280 | 281 | return $systemXmlPaths; 282 | } 283 | 284 | /** 285 | * Checks if any diff entry is available. 286 | * 287 | * @return bool 288 | */ 289 | public function diffsAvailable() 290 | { 291 | $models = array( 292 | 'config' => Mage::getModel('techdivision_systemconfigdiff/config'), 293 | 'page' => Mage::getModel('techdivision_systemconfigdiff/page'), 294 | 'block' => Mage::getModel('techdivision_systemconfigdiff/block') 295 | ); 296 | 297 | foreach($models as $model){ 298 | if($model->getCollection()->count() > 0) return true; 299 | } 300 | 301 | return false; 302 | } 303 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Block.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Block 25 | extends Mage_Core_Model_Abstract 26 | { 27 | 28 | public function _construct() 29 | { 30 | $this->_init('techdivision_systemconfigdiff/block'); 31 | } 32 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Config.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Config 25 | extends Mage_Core_Model_Abstract 26 | { 27 | 28 | public function _construct() 29 | { 30 | $this->_init('techdivision_systemconfigdiff/config'); 31 | } 32 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Differ.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | abstract class TechDivision_SystemConfigDiff_Model_Differ 25 | extends Mage_Core_Model_Abstract 26 | { 27 | /** 28 | * Initiates the diff 29 | */ 30 | abstract function diff($thisConfig, $otherConfig); 31 | 32 | /** 33 | * Returns the system data as array 34 | * 35 | * @return mixed 36 | */ 37 | abstract function getSystemData(); 38 | 39 | /** 40 | * Depth First Search algorithm to flatten an multi associative array. 41 | * All keys will be merged to a path, separated by / 42 | * The last value (leaf of tree) will be stored as: path => value 43 | * 44 | * @param $arr The multi associative array 45 | * @param $path The start path, usually '' 46 | * @return array Array of path => value 47 | */ 48 | protected function _flattenArray($arr, $path){ 49 | $result = array(); 50 | 51 | if(!is_array($arr)){ 52 | return array($path => $arr); 53 | } 54 | 55 | foreach($arr as $key => $value){ 56 | $_path = $path; 57 | $_path = $_path . '/' . $key; 58 | $res = $this->_flattenArray($value, $_path); 59 | $result = array_merge($res, $result); 60 | } 61 | 62 | return $result; 63 | } 64 | 65 | /** 66 | * Does the diff of two arrays and returns the diff as array 67 | */ 68 | protected function _diffFromArrays($arr1, $arr2){ 69 | $result = array(); 70 | 71 | $result[1] = array_diff_assoc($arr1, $arr2); 72 | $result[2] = array_diff_assoc($arr2, $arr1); 73 | 74 | return $result; 75 | } 76 | 77 | /** 78 | * Empties the database tables for the given model 79 | * 80 | * @param $model The model's database table to be emptied 81 | */ 82 | protected function _emptyDb($model){ 83 | $collection = Mage::getModel('techdivision_systemconfigdiff/'. $model)->getCollection(); 84 | foreach($collection as $entry){ 85 | $entry->delete(); 86 | } 87 | } 88 | 89 | /** 90 | * Returns the config helper 91 | * 92 | * @return Mage_Core_Helper_Abstract 93 | */ 94 | protected function _getConfigHelper(){ 95 | return Mage::helper('techdivision_systemconfigdiff/config'); 96 | } 97 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Differ/Cms.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Differ_Cms extends TechDivision_SystemConfigDiff_Model_Differ 25 | { 26 | /** 27 | * The diff key defines the data for this differ in the system data array 28 | */ 29 | const DIFF_KEY_PAGE = "page"; 30 | const DIFF_KEY_BLOCK = "block"; 31 | 32 | /** 33 | * @inheritdoc 34 | */ 35 | public function diff($thisConfig, $otherConfig){ 36 | // Empty database tables 37 | $this->_emptyDb(self::DIFF_KEY_PAGE); 38 | $this->_emptyDb(self::DIFF_KEY_BLOCK); 39 | 40 | $this->_diff($thisConfig, $otherConfig, self::DIFF_KEY_PAGE); 41 | $this->_diff($thisConfig, $otherConfig, self::DIFF_KEY_BLOCK); 42 | } 43 | 44 | /** 45 | * Returns all cms pages/blocks 46 | * 47 | * @param $cmsId Either 'page' or 'block' 48 | * @return array 49 | */ 50 | public function getSystemData(){ 51 | return array( 52 | self::DIFF_KEY_PAGE => $this->_getSystemData(self::DIFF_KEY_PAGE), 53 | self::DIFF_KEY_BLOCK => $this->_getSystemData(self::DIFF_KEY_BLOCK) 54 | ); 55 | } 56 | 57 | /** 58 | * Diffs the two cms contents 59 | * 60 | * @param $thisCms The cms data of this system 61 | * @param $otherCms The cms data of the other system 62 | * @param $cmsId Either 'page' or 'block' 63 | */ 64 | protected function _diff($thisCms, $otherCms, $cmsId){ 65 | // Both system's cms content 66 | $system1 = $thisCms[$cmsId]; 67 | $system2 = $otherCms[$cmsId]; 68 | 69 | // Remember the cms content which already has been persisted 70 | $cmsAlreadyDone = array(); 71 | 72 | // For each cms entry from system1 73 | foreach($system1 as $identifier => $storeIds){ 74 | 75 | // Array for all identifier/store pairs 76 | $cmsAlreadyDone[$identifier] = array(); 77 | 78 | // For each store specific cms content 79 | foreach($storeIds as $storeId => $value1){ 80 | 81 | // The data to save 82 | $toSave = array(); 83 | 84 | // Get the cms content by identifier from system2, can be null if not set in system2 85 | if(array_key_exists($identifier, $system2) && array_key_exists($storeId, $system2[$identifier])){ 86 | $value2 = $system2[$identifier][$storeId]['content']; 87 | } else { 88 | $value2 = null; 89 | } 90 | 91 | $value1 = $value1['content']; 92 | 93 | // If cms content is different save it do database 94 | if($value1 !== $value2){ 95 | $toSave['identifier'] = $identifier; 96 | $toSave['store_name'] = Mage::getModel('core/store')->load($storeId)->getName(); 97 | $toSave['system1_content'] = $value1; 98 | $toSave['system2_content'] = $value2; 99 | 100 | Mage::getModel('techdivision_systemconfigdiff/' . $cmsId)->addData($toSave)->save(); 101 | } 102 | 103 | // Cms entry already persisted 104 | $cmsAlreadyDone[$identifier][] = $storeId; 105 | } 106 | } 107 | 108 | // Reverse: if system2 has cms entries which are not set in system1 109 | foreach($system2 as $identifier => $storeIds){ 110 | 111 | // For each store specific cms content 112 | foreach($storeIds as $storeId => $value2){ 113 | 114 | // The data to save 115 | $toSave = array(); 116 | 117 | // Skip all already persisted cms entries 118 | if(array_key_exists($identifier, $cmsAlreadyDone) && in_array($storeId, $cmsAlreadyDone[$identifier])){ 119 | continue; 120 | } 121 | 122 | $value2 = $value2['content']; 123 | 124 | $toSave['identifier'] = $identifier; 125 | $toSave['store_name'] = Mage::getModel('core/store')->load($storeId)->getName(); 126 | $toSave['system1_content'] = null; 127 | $toSave['system2_content'] = $value2; 128 | 129 | Mage::getModel('techdivision_systemconfigdiff/' . $cmsId)->addData($toSave)->save(); 130 | } 131 | } 132 | } 133 | 134 | /** 135 | * Returns the content of cms pages/blocks 136 | * 137 | * @param $cmsId Either 'page' or 'block' 138 | * @return array 139 | */ 140 | protected function _getSystemData($cmsId){ 141 | $result = array(); 142 | 143 | // Get cms resource model to load collection 144 | $cms = Mage::getModel('cms/' . $cmsId); 145 | $cmsResource = $cms->getResource(); 146 | 147 | // For every cms entry 148 | foreach($cms->getCollection() as $_cms){ 149 | // Get the store ids the cms content belongs to, title, identifier and content 150 | $storeIds = $cmsResource->lookupStoreIds($_cms->getId()); 151 | $title = $_cms->getTitle(); 152 | $identifier = $_cms->getIdentifier(); 153 | $content = $_cms->getContent(); 154 | 155 | // Save the data for every identifier/store pair 156 | foreach($storeIds as $storeId){ 157 | $result[$identifier][$storeId] = array( 158 | 'title' => $title, 159 | 'content' => $content 160 | ); 161 | } 162 | } 163 | 164 | // Return the data array 165 | return $result; 166 | } 167 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Differ/Config.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Differ_Config extends TechDivision_SystemConfigDiff_Model_Differ 25 | { 26 | /** 27 | * The diff key defines the data for this differ in the system data array 28 | */ 29 | const DIFF_KEY = "config"; 30 | 31 | /** 32 | * @var array Contains all paths specified all system.xml files 33 | */ 34 | protected $_systemXmlPaths; 35 | 36 | /** 37 | * @inheritdoc 38 | */ 39 | public function diff($thisConfig, $otherConfig){ 40 | $thisConfig = $thisConfig[self::DIFF_KEY]; 41 | $otherConfig = $otherConfig[self::DIFF_KEY]; 42 | 43 | // Flatten both config arrays 44 | $thisConfig['default'] = $this->_flattenArray($thisConfig['default'], ''); 45 | $thisConfig['websites'] = $this->_flattenArray($thisConfig['websites'], ''); 46 | $thisConfig['stores'] = $this->_flattenArray($thisConfig['stores'], ''); 47 | $otherConfig['default'] = $this->_flattenArray($otherConfig['default'], ''); 48 | $otherConfig['websites'] = $this->_flattenArray($otherConfig['websites'], ''); 49 | $otherConfig['stores'] = $this->_flattenArray($otherConfig['stores'], ''); 50 | 51 | // Do the actual diff 52 | $diff = array(); 53 | $diff['default'] = $this->_diffFromArrays($thisConfig['default'], $otherConfig['default']); 54 | $diff['websites'] = $this->_diffFromArrays($thisConfig['websites'], $otherConfig['websites']); 55 | $diff['stores'] = $this->_diffFromArrays($thisConfig['stores'], $otherConfig['stores']); 56 | 57 | // Empty database tables 58 | $this->_emptyDb(self::DIFF_KEY); 59 | 60 | // Save new diff 61 | $this->_saveDiff($diff); 62 | } 63 | 64 | /** 65 | * Returns the system config for all scopes (default, websites, stores) 66 | * 67 | * @return array 68 | */ 69 | public function getSystemData(){ 70 | /** @var Mage_Core_Model_Config $config */ 71 | $config = Mage::app()->getConfig(); 72 | $config->loadDb(); 73 | 74 | /* 75 | * Get config for each scope (default, websites, stores) 76 | * default: default/path 77 | * websites: websites/WEBSITE_CODE/path 78 | * stores: stores/STORE_CODE/path 79 | * 80 | * example: WEBSITE_CODE = 'Deutschland', STORE_CODE = 'de_DE' 81 | * 82 | * Contains also content of , , tags 83 | * of every config.xml 84 | */ 85 | $result = array( 86 | 'default' => $config->getNode('default')->asArray(), 87 | 'websites' => $config->getNode('websites')->asArray(), 88 | 'stores' => $config->getNode('stores')->asArray() 89 | ); 90 | 91 | return array(self::DIFF_KEY => $result); 92 | } 93 | 94 | /** 95 | * Saves the diff array to the database 96 | * 97 | * @param $diff 98 | */ 99 | protected function _saveDiff($diff){ 100 | /* @var TechDivision_SystemConfigDiff_Helper_Data $helper */ 101 | $helper = Mage::helper('techdivision_systemconfigdiff'); 102 | 103 | // Get array with system.xml paths 104 | $this->_systemXmlPaths = $helper->getSystemXmlPaths(); 105 | 106 | // For every scope (default, websites, stores) 107 | foreach($diff as $scope => $scopeData){ 108 | 109 | // Both system's data 110 | $system1 = $scopeData[1]; 111 | $system2 = $scopeData[2]; 112 | 113 | // The data to save 114 | $toSave = array(); 115 | 116 | // Remember the paths which already have been persisted 117 | $pathsAlreadyDone = array(); 118 | 119 | // For each path from system1 120 | foreach($system1 as $path => $value1){ 121 | 122 | // Ignore config data of this module 123 | if(strpos($path, $this->_getConfigHelper()->getModuleAlias())){ 124 | $pathsAlreadyDone[] = $path; 125 | continue; 126 | } 127 | 128 | // Get the value by path from system2, can be null if not set in system2 129 | if(array_key_exists($path, $system2)){ 130 | $value2 = $system2[$path]; 131 | } else { 132 | $value2 = null; 133 | } 134 | 135 | // Extract the scope id from path 136 | $pathScopeData = $this->_extractScopeId($scope, $path); 137 | 138 | $toSave['path'] = $pathScopeData['path']; 139 | $toSave['scope'] = $scope; 140 | $toSave['scope_id'] = $pathScopeData['scope_id']; 141 | $toSave['scope_name'] = $pathScopeData['scope_name']; 142 | $toSave['code'] = $pathScopeData['code']; 143 | $toSave['system1_value'] = $value1; 144 | $toSave['system2_value'] = $value2; 145 | $this->_isSystemXmlPath($pathScopeData['path']) ? $toSave['systemXml'] = 1 : $toSave['systemXml'] = 0; 146 | 147 | /** 148 | * @var TechDivision_SystemConfigDiff_Model_Config $config 149 | */ 150 | $config = Mage::getModel('techdivision_systemconfigdiff/config'); 151 | // Save data 152 | $config->addData($toSave)->save(); 153 | 154 | // Path already persisted 155 | $pathsAlreadyDone[] = $path; 156 | } 157 | 158 | // Reverse: if system2 has values which are not set in system1 159 | foreach($system2 as $path => $value2){ 160 | 161 | // Skip all already persisted paths 162 | if(in_array($path, $pathsAlreadyDone)){ 163 | continue; 164 | } 165 | 166 | // Extract the scope id from path 167 | $pathScopeData = $this->_extractScopeId($scope, $path); 168 | 169 | $toSave['path'] = $pathScopeData['path']; 170 | $toSave['scope'] = $scope; 171 | $toSave['scope_id'] = $pathScopeData['scope_id']; 172 | $toSave['scope_name'] = $pathScopeData['scope_name']; 173 | $toSave['code'] = $pathScopeData['code']; 174 | $toSave['system1_value'] = null; 175 | $toSave['system2_value'] = $value2; 176 | $this->_isSystemXmlPath($pathScopeData['path']) ? $toSave['systemXml'] = 1 : $toSave['systemXml'] = 0; 177 | 178 | /** 179 | * @var TechDivision_SystemConfigDiff_Model_Config $config 180 | */ 181 | $config = Mage::getModel('techdivision_systemconfigdiff/config'); 182 | // Save data 183 | $config->addData($toSave)->save(); 184 | } 185 | } 186 | } 187 | 188 | /** 189 | * Extracts the scope code from the path and returns the scope id and path 190 | * 191 | * @param $scope The actual scope context 192 | * @param $path The config path 193 | * @return array 194 | */ 195 | protected function _extractScopeId($scope, $path){ 196 | // Return 'Default' for default scope 197 | if($scope === 'default'){ 198 | return array('scope_id' => 0, 'path' => substr($path, 1), 'scope_name' => 'Default', 'code' => ''); 199 | } else 200 | if($scope === 'websites'){ 201 | $_scope = 'website'; 202 | } else 203 | if($scope === 'stores'){ 204 | $_scope = 'store'; 205 | } 206 | 207 | // Get scope specific collection model 208 | $scopeCode = explode('/', $path, 3); 209 | $collection = Mage::getModel('core/' . $_scope)->getCollection(); 210 | 211 | // Activate default website/store loading 212 | $collection->setFlag('load_default_' . $_scope, true); 213 | 214 | // Get website/store ($scopeItem) 215 | $scopeItem = $collection->addFieldToFilter('code', $scopeCode[1])->getFirstItem(); 216 | 217 | // Get id and name of website/store 218 | $id = call_user_func(array($scopeItem, 'get' . ucfirst($_scope) . 'Id')); 219 | if(!is_null($id)){ 220 | $name = $scopeItem->getName(); 221 | } else { 222 | // If this system misses website/store 223 | $name = 'MISSING ' . strtoupper($_scope); 224 | } 225 | 226 | return array('scope_id' => $id, 'path' => $scopeCode[2], 'scope_name' => $name, 'code' => $scopeCode[1]); 227 | } 228 | 229 | /** 230 | * Checks if given path is a path defined by a system.xml file 231 | * 232 | * @param $path The path to be checked 233 | * @return bool 234 | */ 235 | protected function _isSystemXmlPath($path){ 236 | foreach($this->_systemXmlPaths as $_path){ 237 | if(strstr($_path, $path)){ 238 | return true; 239 | } 240 | } 241 | return false; 242 | } 243 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Observer.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Observer 25 | { 26 | /** 27 | * Interrupts the layout rendering to inject custom templates, js and css 28 | * 29 | * @param $observer 30 | */ 31 | public function updateTemplate($observer){ 32 | $controller = Mage::app()->getRequest()->getControllerName(); 33 | $action = Mage::app()->getRequest()->getActionName(); 34 | $moduleName = Mage::app()->getRequest()->getModuleName(); 35 | 36 | // Add css and js to System -> Config diff 37 | if('admin_techdivision_systemconfigdiff' === $moduleName){ 38 | $headBlock = Mage::getSingleton('core/layout')->getBlock('head'); 39 | $headBlock->addCss('css/techdivision/systemconfigdiff/diff.css'); 40 | $headBlock->addItem('skin_js', 'js/techdivision/systemconfigdiff/jquery-1.9.1.min.js'); 41 | $headBlock->addItem('skin_js', 'js/techdivision/systemconfigdiff/diff.js'); 42 | } 43 | 44 | // Add css and update template to System -> Config 45 | if('system_config' === $controller && 'edit' === $action){ 46 | $displayDiff = Mage::helper('techdivision_systemconfigdiff/config')->getDisplaysettingsShowDiff(); 47 | $layout = Mage::getSingleton('core/layout'); 48 | 49 | $headBlock = $layout->getBlock('head'); 50 | $switcherBlock = $layout->getBlock('adminhtml.system.config.switcher'); 51 | $tabBlock = $layout->getBlock('left.child1'); 52 | 53 | // If display diff is set to true 54 | if($displayDiff){ 55 | $headBlock->addCss('css/techdivision/systemconfigdiff/diff.css'); 56 | $headBlock->addItem('skin_js', 'js/techdivision/systemconfigdiff/jquery-1.9.1.min.js'); 57 | $headBlock->addItem('skin_js', 'js/techdivision/systemconfigdiff/diff.js'); 58 | $switcherBlock->setTemplate('techdivision/systemconfigdiff/switcher.phtml'); 59 | $tabBlock->setTemplate('techdivision/systemconfigdiff/tabs.phtml'); 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Page.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Page 25 | extends Mage_Core_Model_Abstract 26 | { 27 | 28 | public function _construct() 29 | { 30 | $this->_init('techdivision_systemconfigdiff/page'); 31 | } 32 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Block.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Block 25 | extends Mage_Core_Model_Mysql4_Abstract 26 | { 27 | 28 | /** 29 | * Init model. 30 | * 31 | * @return void 32 | */ 33 | protected function _construct() 34 | { 35 | $this->_init( 36 | 'techdivision_systemconfigdiff/diff_block', 37 | 'techdivision_systemconfigdiff_diff_block_id' 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Block/Collection.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Block_Collection 25 | extends Mage_Core_Model_Mysql4_Collection_Abstract 26 | { 27 | /** 28 | * Declare base table and mapping of some fields. 29 | * 30 | * @return void. 31 | */ 32 | protected function _construct() 33 | { 34 | $this->_init('techdivision_systemconfigdiff/block'); 35 | } 36 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Config.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Config 25 | extends Mage_Core_Model_Mysql4_Abstract 26 | { 27 | 28 | /** 29 | * Init model. 30 | * 31 | * @return void 32 | */ 33 | protected function _construct() 34 | { 35 | $this->_init( 36 | 'techdivision_systemconfigdiff/diff_config', 37 | 'techdivision_systemconfigdiff_diff_config_id' 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Config/Collection.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Config_Collection 25 | extends Mage_Core_Model_Mysql4_Collection_Abstract 26 | { 27 | /** 28 | * Declare base table and mapping of some fields. 29 | * 30 | * @return void. 31 | */ 32 | protected function _construct() 33 | { 34 | $this->_init('techdivision_systemconfigdiff/config'); 35 | } 36 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Page.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Page 25 | extends Mage_Core_Model_Mysql4_Abstract 26 | { 27 | 28 | /** 29 | * Init model. 30 | * 31 | * @return void 32 | */ 33 | protected function _construct() 34 | { 35 | $this->_init( 36 | 'techdivision_systemconfigdiff/diff_page', 37 | 'techdivision_systemconfigdiff_diff_page_id' 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Page/Collection.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Page_Collection 25 | extends Mage_Core_Model_Mysql4_Collection_Abstract 26 | { 27 | /** 28 | * Declare base table and mapping of some fields. 29 | * 30 | * @return void. 31 | */ 32 | protected function _construct() 33 | { 34 | $this->_init('techdivision_systemconfigdiff/page'); 35 | } 36 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Resource/Setup.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Resource_Setup 25 | extends Mage_Eav_Model_Entity_Setup 26 | { 27 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Service/Api.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Service_Api extends Mage_Api_Model_Resource_Abstract 25 | { 26 | 27 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/Service/Api/V2.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_Service_Api_V2 extends TechDivision_SystemConfigDiff_Model_Service_Api 25 | { 26 | /** 27 | * Returns all data defined by the differs 28 | * 29 | * @return string 30 | */ 31 | public function getWebshopConfig() 32 | { 33 | /** 34 | * @var TechDivision_SystemConfigDiff_Helper_Config $configHelper 35 | */ 36 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 37 | 38 | $systemData = array(); 39 | foreach($configHelper->getDiffers() as $differ) { 40 | $systemData = array_merge($differ->getSystemData(), $systemData); 41 | } 42 | 43 | return json_encode($systemData); 44 | } 45 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/System/Config/Source/Paths.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Model_System_Config_Source_Paths 25 | { 26 | /** 27 | * @var The system.xml config paths 28 | */ 29 | protected $_paths; 30 | 31 | public function __construct() 32 | { 33 | /* @var TechDivision_SystemConfigDiff_Helper_Data $helper */ 34 | $helper = Mage::helper('techdivision_systemconfigdiff'); 35 | 36 | // Get array with system.xml paths 37 | $this->_paths = $helper->getSystemXmlPaths(); 38 | sort($this->_paths); 39 | } 40 | 41 | public function toOptionArray(){ 42 | $result = array(); 43 | 44 | foreach($this->_paths as $path){ 45 | $result[] = array( 46 | 'value' => $path, 47 | 'label' => $path 48 | ); 49 | } 50 | 51 | return $result; 52 | } 53 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/Model/SystemDiff.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigdiff_Model_SystemDiff 25 | { 26 | /** 27 | * Calls the webservice of the other system to get the system data 28 | * and starts the diff for all configured diffs in the backend. 29 | */ 30 | public function systemDiff() 31 | { 32 | /** 33 | * @var TechDivision_SystemConfigDiff_Helper_Config $configHelper 34 | */ 35 | $configHelper = Mage::helper('techdivision_systemconfigdiff/config'); 36 | 37 | // Get API credentials 38 | $apiUrl = $configHelper->getSystemsettingsSystemUrl(); 39 | $apiUser = $configHelper->getSystemsettingsUser(); 40 | $apiPwd = $configHelper->getSystemsettingsPassword(); 41 | if(!$apiUrl){ 42 | throw new Exception('Missing API configuration!'); 43 | } 44 | 45 | // Set up the web service client 46 | $proxy = new SoapClient($apiUrl); 47 | 48 | // Login and get system config of other system 49 | if($configHelper->getSystemsettingsWsi()){ 50 | $session = $proxy->login(array( 51 | 'username' => $apiUser, 52 | 'apiKey' => $apiPwd 53 | )); 54 | $sessionId = $session->result; 55 | $otherConfig = $proxy->systemConfigGetConfig(array('sessionId' => $sessionId)); 56 | $otherConfig = $otherConfig->result; 57 | } else { 58 | $sessionId = $proxy->login($apiUser, $apiPwd); 59 | $otherConfig = $proxy->systemConfigGetConfig($sessionId); 60 | } 61 | 62 | // Deserialize the result 63 | $otherConfig = json_decode($otherConfig, true); 64 | 65 | // Get system config of this system 66 | $thisConfig = array(); 67 | foreach($configHelper->getDiffers() as $differ) { 68 | $thisConfig = array_merge($differ->getSystemData(), $thisConfig); 69 | } 70 | 71 | // All registered differs do the diff 72 | foreach($configHelper->getDiffers() as $differ) { 73 | $differ->diff($thisConfig, $otherConfig); 74 | } 75 | } 76 | 77 | /** 78 | * Replaces the config by the given diff defined by filter array. 79 | * 80 | * @param $diffModel The diff model the diff belongs to 81 | * @param $filterArray The filter array specifies the diff 82 | * @return bool (Un-)successful 83 | */ 84 | public function replaceConfig($diffModel, $filterArray) 85 | { 86 | $baseUrlPaths = array(); 87 | if(!Mage::helper('techdivision_systemconfigdiff/config')->getSystemsettingsBaseUrlReplaceEnabled()){ 88 | $baseUrlPaths[] = 'web/unsecure/base_url'; 89 | $baseUrlPaths[] = 'web/secure/base_url'; 90 | } 91 | 92 | // Find the diff entry specified by filter array 93 | $collection = Mage::getModel('techdivision_systemconfigdiff/' . $diffModel)->getCollection(); 94 | foreach($filterArray as $filter => $filterValue){ 95 | $collection->addFieldToFilter($filter, $filterValue); 96 | } 97 | 98 | // If no data was found 99 | if($collection->count() === 0){ 100 | return false; 101 | } 102 | 103 | // If entry was found 104 | foreach($collection as $entry){ 105 | // Save the config value from other system 106 | $value = $entry->getSystem2Value(); 107 | $path = $entry->getPath(); 108 | 109 | // Skip if path is base url specific 110 | if(in_array($path, $baseUrlPaths)) continue; 111 | 112 | $scope = $entry->getScope(); 113 | $scopeId = $entry->getScopeId(); 114 | 115 | /* @var Mage_Core_Model_Resource_Config $configResource */ 116 | $configResource = Mage::getResourceModel('core/config'); 117 | $configResource->saveConfig($path, $value, $scope, $scopeId); 118 | 119 | // Delete the diff entry 120 | /* @var TechDivision_SystemConfigDiff_Helper_Data $helper */ 121 | $helper = Mage::helper('techdivision_systemconfigdiff'); 122 | $helper->deleteDiff($entry, $path, $scope, $scopeId); 123 | } 124 | 125 | // Deletion successful 126 | return true; 127 | } 128 | 129 | /** 130 | * Gets called by cron job and starts diff if enabled. 131 | */ 132 | public function doCron() 133 | { 134 | if(Mage::helper('techdivision_systemconfigdiff/config')->getSystemsettingsCronEnabled()){ 135 | $this->systemDiff(); 136 | } 137 | 138 | return; 139 | } 140 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/controllers/Adminhtml/IndexController.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class TechDivision_SystemConfigDiff_Adminhtml_IndexController 25 | extends Mage_Adminhtml_Controller_Action 26 | { 27 | protected function _initAction() 28 | { 29 | $this->loadLayout() 30 | ->_setActiveMenu('techdivision_systemconfigdiff/diff_overview') 31 | ->_addBreadcrumb('diff overview','diff overview'); 32 | 33 | return $this; 34 | } 35 | 36 | /** 37 | * Index action 38 | * 39 | * @return void 40 | */ 41 | public function indexAction() 42 | { 43 | $this->loadLayout(); 44 | $this->renderLayout(); 45 | } 46 | 47 | /** 48 | * New action 49 | * 50 | * @return void 51 | */ 52 | public function newAction() 53 | { 54 | // Get system diff model to start the diff 55 | try{ 56 | $this->getSystemDiffModel()->systemDiff(); 57 | }catch(Exception $e){ 58 | Mage::getSingleton('core/session')->addError('SOAP error: ' . $e->getMessage()); 59 | $this->_redirect('*/*/'); 60 | return false; 61 | } 62 | 63 | // Redirect to overview 64 | $this->_redirect('*/*/'); 65 | } 66 | 67 | /** 68 | * Update action 69 | * 70 | * @return void 71 | */ 72 | public function updateAction(){ 73 | try{ 74 | // Get path, scope and scopeId from Ajax call 75 | $params = $this->getRequest()->getparams(); 76 | $filterArray = array( 77 | 'path' => $params['path'], 78 | 'scope' => $params['scope'], 79 | 'scope_id' => $params['scopeId'] 80 | ); 81 | 82 | if($this->getSystemDiffModel()->replaceConfig('config', $filterArray)){ 83 | echo 1; 84 | return; 85 | } else { 86 | // No entry found 87 | echo 0; 88 | return; 89 | } 90 | } catch(Exception $e){ 91 | // In case of something went wrong 92 | Mage::logException($e); 93 | echo 0; 94 | return; 95 | } 96 | } 97 | 98 | /** 99 | * Replace all action 100 | * 101 | * @return void 102 | */ 103 | public function replaceAllAction(){ 104 | $systemDiff = $this->getSystemDiffModel(); 105 | 106 | $systemDiff->replaceConfig('config', array()); 107 | $systemDiff->replaceConfig('page', array()); 108 | $systemDiff->replaceConfig('block', array()); 109 | 110 | // Redirect to overview 111 | $this->_redirect('*/*/'); 112 | } 113 | 114 | /** 115 | * SystemGrid action 116 | * 117 | * @return void 118 | */ 119 | public function systemGridAction(){ 120 | $this->getResponse()->setBody( 121 | $this->getLayout()->createBlock('techdivision_systemconfigdiff/adminhtml_overview_tabs_systemConfig', 'tab_systemConfig') 122 | ->toHtml() 123 | ); 124 | } 125 | 126 | /** 127 | * ConfigGrid action 128 | * 129 | * @return void 130 | */ 131 | public function configGridAction(){ 132 | $this->getResponse()->setBody( 133 | $this->getLayout() 134 | ->createBlock('techdivision_systemconfigdiff/adminhtml_overview_tabs_config', 'tab_config') 135 | ->toHtml() 136 | ); 137 | } 138 | 139 | /** 140 | * PageGrid action 141 | * 142 | * @return void 143 | */ 144 | public function pageGridAction(){ 145 | $this->getResponse()->setBody( 146 | $this->getLayout() 147 | ->createBlock('techdivision_systemconfigdiff/adminhtml_overview_tabs_page', 'tab_page') 148 | ->toHtml() 149 | ); 150 | } 151 | 152 | /** 153 | * BlockGrid action 154 | * 155 | * @return void 156 | */ 157 | public function blockGridAction(){ 158 | $this->getResponse()->setBody( 159 | $this->getLayout() 160 | ->createBlock('techdivision_systemconfigdiff/adminhtml_overview_tabs_block', 'tab_block') 161 | ->toHtml() 162 | ); 163 | } 164 | 165 | /** 166 | * @return false|TechDivision_SystemConfigDiff_Model_SystemDiff 167 | */ 168 | protected function getSystemDiffModel(){ 169 | return Mage::getModel('techdivision_systemconfigdiff/systemDiff'); 170 | } 171 | } -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/etc/api.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | 28 | 29 | 30 | techdivision_systemconfigdiff/service_api 31 | System Config Resource 32 | systemconfig 33 | 34 | 35 | Getting System Config 36 | systemconfig/getConfig 37 | getWebshopConfig 38 | 39 | 40 | 41 | 42 | 43 | system_config 44 | 45 | 46 | 47 | systemConfig 48 | 49 | 50 | 51 | 52 | 53 | System Config 54 | 1 55 | 56 | Getting Config 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | 28 | 29 | 0.1.5beta 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | TechDivision_SystemConfigDiff.csv 38 | 39 | 40 | 41 | 42 | 43 | 44 | standard 45 | 46 | TechDivision_SystemConfigDiff 47 | techdivision_systemconfigdiff 48 | 49 | 50 | 51 | 52 | 53 | 54 | techdivision/systemconfigdiff.xml 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | admin 63 | 64 | TechDivision_SystemConfigDiff 65 | admin_techdivision_systemconfigdiff 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | TechDivision_SystemConfigDiff.csv 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Config Diff 85 | 1 86 | techdivision_systemconfigdiff/adminhtml_index 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | Stub 101 | 50 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | techdivision/systemconfigdiff.xml 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | singleton 123 | techdivision_systemconfigdiff/observer 124 | updateTemplate 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | TechDivision_SystemConfigDiff_Model 134 | techdivision_systemconfigdiff_resource 135 | 136 | 137 | TechDivision_SystemConfigDiff_Model_Resource 138 | 139 | 140 | techdivision_systemconfigdiff_diff_config
141 |
142 | 143 | techdivision_systemconfigdiff_diff_page
144 |
145 | 146 | techdivision_systemconfigdiff_diff_block
147 |
148 |
149 |
150 |
151 | 152 | 153 | 154 | TechDivision_SystemConfigDiff 155 | TechDivision_SystemConfigDiff_Model_Resource_Setup 156 | 157 | 158 | core_setup 159 | 160 | 161 | 162 | 163 | core_write 164 | 165 | 166 | 167 | 168 | core_read 169 | 170 | 171 | 172 | 173 | 174 | TechDivision_SystemConfigDiff_Block 175 | 176 | 177 | 178 | TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field 179 | TechDivision_SystemConfigDiff_Block_Adminhtml_System_Config_Form_Field_Regexceptions 180 | 181 | 182 | 183 | 184 | 185 | TechDivision_SystemConfigDiff_Helper 186 | 187 | 188 | 189 | 190 | techdivision_systemconfigdiff/differ_config 191 | 192 | 193 | techdivision_systemconfigdiff/differ_cms 194 | 195 | 196 |
197 | 198 | 199 | 200 | 201 | techdivision_systemconfigdiff/systemsettings/cron 202 | 203 | 204 | techdivision_systemconfigdiff/systemDiff::doCron 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 10 1 * * * 213 | 214 | 215 | 216 |
-------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/etc/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | 28 | 29 | 30 | 301 31 | 32 | 33 | 34 | 35 | 36 | techdivision 37 | 130 38 | 1 39 | 1 40 | 1 41 | 42 | 43 | 44 | text 45 | 10 46 | 1 47 | 1 48 | 1 49 | 50 | 51 | 52 | The API url of the other system 53 | text 54 | 10 55 | 1 56 | 1 57 | 1 58 | required-entry 59 | 60 | 61 | 62 | text 63 | 20 64 | 1 65 | 1 66 | 1 67 | required-entry 68 | 69 | 70 | 71 | password 72 | 30 73 | 1 74 | 1 75 | 1 76 | required-entry 77 | 78 | 79 | 80 | select 81 | adminhtml/system_config_source_yesno 82 | 40 83 | 1 84 | 1 85 | 1 86 | 87 | 88 | 89 | select 90 | adminhtml/system_config_source_yesno 91 | 50 92 | 1 93 | 1 94 | 1 95 | 96 | 97 | 98 | text 99 | 60 100 | 1 101 | 1 102 | 1 103 | Use crontab format (e.g. 10 1 * * * for 1:10 am) 104 | 105 | 106 | 107 | select 108 | adminhtml/system_config_source_yesno 109 | 70 110 | 1 111 | 1 112 | 1 113 | 114 | 115 | 116 | 117 | 118 | text 119 | 20 120 | 1 121 | 1 122 | 1 123 | 124 | 125 | 126 | text 127 | 10 128 | 1 129 | 1 130 | 1 131 | required-entry 132 | 133 | 134 | 135 | text 136 | 20 137 | 1 138 | 1 139 | 1 140 | required-entry 141 | 142 | 143 | 144 | select 145 | adminhtml/system_config_source_yesno 146 | 30 147 | 1 148 | 1 149 | 1 150 | required-entry 151 | 152 | 153 | 154 | multiselect 155 | techdivision_systemconfigdiff/system_config_source_paths 156 | 40 157 | 1 158 | 1 159 | 1 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/etc/wsdl.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 29 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Get the system config 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/etc/wsi.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | Get the system config 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/app/code/community/TechDivision/SystemConfigDiff/sql/techdivision_systemconfigdiff_setup/mysql4-install-0.1.0beta.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | 25 | /* initiate installer ********************************************************/ 26 | /** @var $setup TechDivision_SystemConfigDiff_Model_Resource_Setup */ 27 | $setup = $this; 28 | 29 | /* start setup ***************************************************************/ 30 | $setup->startSetup(); 31 | 32 | /* do setup ******************************************************************/ 33 | $setup->run(" 34 | CREATE TABLE IF NOT EXISTS `{$this->getTable('techdivision_systemconfigdiff_diff_config')}` ( 35 | `techdivision_systemconfigdiff_diff_config_id` INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, 36 | `path` VARCHAR(255) NOT NULL, 37 | `scope` VARCHAR(8) NOT NULL, 38 | `scope_id` INT(8) NOT NULL, 39 | `scope_name` VARCHAR(255) NOT NULL, 40 | `code` VARCHAR(255) NOT NULL, 41 | `system1_value` TEXT, 42 | `system2_value` TEXT, 43 | `systemXml` TINYINT NOT NULL 44 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 45 | 46 | CREATE TABLE IF NOT EXISTS `{$this->getTable('techdivision_systemconfigdiff_diff_page')}` ( 47 | `techdivision_systemconfigdiff_diff_page_id` INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, 48 | `identifier` VARCHAR(255) NOT NULL, 49 | `store_name` VARCHAR(255) NOT NULL, 50 | `system1_content` MEDIUMTEXT, 51 | `system2_content` MEDIUMTEXT 52 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 53 | 54 | CREATE TABLE IF NOT EXISTS `{$this->getTable('techdivision_systemconfigdiff_diff_block')}` ( 55 | `techdivision_systemconfigdiff_diff_block_id` INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY, 56 | `identifier` VARCHAR(255) NOT NULL, 57 | `store_name` VARCHAR(255) NOT NULL, 58 | `system1_content` MEDIUMTEXT, 59 | `system2_content` MEDIUMTEXT 60 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 61 | "); 62 | 63 | /* end setup *****************************************************************/ 64 | $setup->endSetup(); -------------------------------------------------------------------------------- /src/app/design/adminhtml/default/default/layout/techdivision/systemconfigdiff.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/app/design/adminhtml/default/default/template/techdivision/systemconfigdiff/switcher.phtml: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | ?> 25 | getValues(); 28 | ?> 29 | 30 |
31 | 32 | getHintHtml() ?> 33 | 53 | isAllowed('system/store')): ?> 54 |

55 | __('Manage Stores') ?> 56 |

57 | 58 |
-------------------------------------------------------------------------------- /src/app/design/adminhtml/default/default/template/techdivision/systemconfigdiff/tabs.phtml: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | ?> 25 | getSectionIds(); 27 | ?> 28 | 29 | getTitle()): ?> 30 |

getTitle() ?>

31 | 32 | getTabs()): ?> 33 | 60 | -------------------------------------------------------------------------------- /src/app/etc/modules/TechDivision_SystemConfigDiff.xml: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | 28 | 29 | true 30 | community 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/app/locale/de_DE/TechDivision_SystemConfigDiff.csv: -------------------------------------------------------------------------------- 1 | "General", "Allgemein" 2 | "SystemConfigDiff", "SystemConfigDiff" 3 | "Systemsettings", "Systemeinstellungen" 4 | "System URL", "System URL" 5 | "API user", "API user" 6 | "API password", "API password" 7 | "Displaysettings", "Anzeigeeinstellungen" 8 | "Alias for this system", "Alias für dieses System" 9 | "Alias for other system", "Alias für anderes System" 10 | "Show diff in system config", "Zeige Diff in Systemkonfiguration" 11 | "Ignore paths", "Zu ignorierende Pfade" 12 | "CMS Blocks", "CMS Blocks" 13 | "blocks", "blocks" 14 | "Block identifier", "Block Identifier" 15 | "Store name", "Store Name" 16 | "Config (config.xml and more)", "Config (config.xml und mehr)" 17 | "config", "config" 18 | "Scope name", "Scope Name" 19 | "Config path", "Config Pfad" 20 | "CMS Pages", "CMS Seiten" 21 | "pages", "pages" 22 | "Page identifier", "Seiten Identifier" 23 | "System Config (system.xml)", "System Config (system.xml)" 24 | "system config", "system config" 25 | "System diff", "System Diff" 26 | "New diff", "Neuer Diff" 27 | "Replace config", "Config ersetzen" 28 | "WS-I compliance", "WS-I kompatibel" 29 | "Enable cron job", "Cron job aktivieren" 30 | "Cronjob for diff update", "Cron Job für Diff Update" 31 | "Use crontab format (e.g. 10 1 * * * for 1:10 am)", "Crontab Format (z.B: 10 1 * * * für 01:10 Uhr)" 32 | "The API url of the other system", "Die API URL des anderen Systems" 33 | "Enable replacement of base url", "Erlaube Ersetzung der Base URL Konfiguration" -------------------------------------------------------------------------------- /src/app/locale/en_US/TechDivision_SystemConfigDiff.csv: -------------------------------------------------------------------------------- 1 | "General", "General" -------------------------------------------------------------------------------- /src/dev/tests/integration/testsuite/TechDivision/SystemConfigDiff/DummyTest.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class TechDivision_SystemConfigDiff_DummyTest extends PHPUnit_Framework_TestCase 24 | { 25 | /** 26 | * This method is a dummy test implementation. 27 | * 28 | * @return void 29 | */ 30 | public function testDummy() 31 | { 32 | $this->assertTrue(TRUE); 33 | } 34 | } -------------------------------------------------------------------------------- /src/dev/tests/unit/testsuite/TechDivision/SystemConfigDiff/DummyTest.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class TechDivision_SystemConfigDiff_DummyTest extends PHPUnit_Framework_TestCase 24 | { 25 | /** 26 | * This method is a dummy test implementation. 27 | * 28 | * @return void 29 | */ 30 | public function testDummy() 31 | { 32 | $this->assertTrue(TRUE); 33 | } 34 | } -------------------------------------------------------------------------------- /src/skin/adminhtml/default/default/css/techdivision/systemconfigdiff/diff.css: -------------------------------------------------------------------------------- 1 | /** 2 | * TechDivision_SystemConfigDiff 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is available through the world-wide-web at this URL: 8 | * http://opensource.org/licenses/osl-3.0.php 9 | */ 10 | 11 | /** 12 | * Css for backend. 13 | * 14 | * @category TechDivision 15 | * @package TechDivision_SystemConfigDiff 16 | * @subpackage Design 17 | * @copyright Copyright (c) 1996-2013 TechDivision GmbH (http://www.techdivision.com) 18 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 19 | * @version ${release.version} 20 | * @since Class available since Release 0.1.0 21 | * @author Florian Sydekum 22 | */ 23 | 24 | /* System -> Config */ 25 | .config-diff-relative {position: relative;} 26 | .switcher-diff-error {background: url("../../../images/techdivision/systemconfigdiff/selectDiffError.png") no-repeat scroll right -3px transparent;} 27 | .tabs-diff-error {background: url(../../../images/error_msg_icon.gif) no-repeat 0px 0px; position: absolute; width: 16px; height: 16px; top: 4px; left: 190px;} 28 | .edit-diff-hidden {display: none;} 29 | .replace-config {margin: 5px 10px 0;} 30 | button.btn-replace span {background-image: url("../../../images/techdivision/systemconfigdiff/bkg_icon-replacebtn.png"); padding-left: 20px;} 31 | 32 | /* System -> Config diff - General */ 33 | .grid table {table-layout: fixed;} 34 | .grid table td {overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} 35 | button.btn-reset.disabled span {background-image: url("../../../images/techdivision/systemconfigdiff/bkg_icon-resetbtn-disabled.png");} 36 | 37 | /* System -> Config diff - Popup */ 38 | #popup {position: absolute; border: 5px solid gray; padding: 10px; background: #fff;} 39 | #system1 {float: left; width: 389px; border-right: 1px solid gray; margin-right: -1px; padding-right: 10px;} 40 | #system2 {float: left; width: 389px; border-left: 1px solid gray; padding-left: 10px;} 41 | #popup .popup-heading {font-weight: bold; text-align: center; border-bottom: 1px solid gray; margin-bottom: 10px;} 42 | #popup .popup-content {word-wrap: break-word;} 43 | #close {background: url(../../../images/dashboard-close.gif) no-repeat 0px 0px; width: 13px; height: 13px; position: absolute; right: 5px; top: 5px;} -------------------------------------------------------------------------------- /src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/bkg_icon-replacebtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/bkg_icon-replacebtn.png -------------------------------------------------------------------------------- /src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/bkg_icon-resetbtn-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/bkg_icon-resetbtn-disabled.png -------------------------------------------------------------------------------- /src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/selectDiffError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techdivision/TechDivision_SystemConfigDiff/28f3a65f302ac5b98d41e94145820a1195908c1f/src/skin/adminhtml/default/default/images/techdivision/systemconfigdiff/selectDiffError.png -------------------------------------------------------------------------------- /src/skin/adminhtml/default/default/js/techdivision/systemconfigdiff/diff.js: -------------------------------------------------------------------------------- 1 | /** 2 | * TechDivision_SystemConfigDiff 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Open Software License (OSL 3.0) 7 | * that is available through the world-wide-web at this URL: 8 | * http://opensource.org/licenses/osl-3.0.php 9 | */ 10 | 11 | /** 12 | * Js for backend. 13 | * 14 | * @category TechDivision 15 | * @package TechDivision_SystemConfigDiff 16 | * @subpackage Javascript 17 | * @copyright Copyright (c) 1996-2013 TechDivision GmbH (http://www.techdivision.com) 18 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 19 | * @version ${release.version} 20 | * @since Class available since Release 0.1.0 21 | * @author Florian Sydekum 22 | */ 23 | jQuery.noConflict(); 24 | 25 | jQuery(document).ready(function(){ 26 | jQuery('.techdivision-systemconfigdiff-adminhtml-index-index .entry-edit').append('' + 27 | '