Problem:
There are 2 addons which were independently from each other created for OpenCart. In addition to providing new classes, they also happen to modify some of the same OpenCart core classes.
For example, both the Export/Import addon and the CMS addon modify the core files
admin/controller/common/header.php
admin/language/english/common/header.php
admin/view/template/common/header.tpl
Solution wanted:
At the the moment we are forced to manually merge the changes from each add-on to the core classes.
Ideally, I'd like to be able to keep an automatic track of all the add-ons in the form of a simple list stored e.g. as separate overwrite directories, and the core class is extended dynamically from that list.
For example, using a cascading overwrite directory named overwrite/<contrib-name>/ :
overwrite/export/admin/controller/common/header.php extends
overwrite/cms/admin/controller/common/header.php which in turn extends the core
/admin/controller/common/header.php
But how would I be able to have a PHP class whose parent class is dynamic? The language doesn't allow for such a feature, or at least I haven't found a solution yet for this.
Any ideas or suggestions are welcome.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Basically its multiple parts:
1. Goto the Admin and choose "Package Manager" - DONE
2. Upload a zip file that contains a mod and it extracts to a temp folder - DONE
3. Copy all files to the correct path structure, making backups of any file that gets replaced to a backup folder. - DONE
After files are copied, there are cases like menus that can be file edited just like SMF and PHPBB do for their mods.
Using SMF's same xml syntax, you can find/replace code automatically. I have this working but have to add error handling. It also handles backups of edited files.
After all files copied and edits made, it zips all the backups and stores them in the backup folder.
To Do:
- Generate a list of files that are changing
- Pre-test the files to ensure they can be modded (i.e. find all the points of entry in existing file)
- Generate a list of installed mods and offer "rollback" options for them
There is also the idea of extending a class. I tried this once but there aren't enough dynamic hook points in the code to check for extended versions of files. This would take a bit more work and I'm still not sure that if we had
class cmsHeader extends ControllerCatalogHeader {
if 2 of the same functions were overridden by 2 different mods, it would still have a problem.
The SMF way seems to handle multiple mods by automatic file edit.
For now, the answer is to simply add a few manual edits to the readme. That is how I handle the CMS mod.. its 2 lines of code that need to be added to the header.tpl file
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Does this mean that SMF is capable of merging the code changes to core classes from different contributions fully automatically? Can it cope with different contributions trying to modify the sane core class, maybe even in the same method?Using SMF's same xml syntax, you can find/replace code automatically. I have this working but have to add error handling. It also handles backups of edited files.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Example (this script adds a require_once config2.php to the index.php file)
Code: Select all
<modification>
<file name="index.php">
<operation>
<search position="after"><![CDATA[
require_once('config.php');
]]></search>
<add><![CDATA[
require_once('config2.php');
]]></add>
</operation>
</file>
</modification>
gets backed up to "index.php_20100503_config2mod"
then a new index.php file is written with the new line added
Resulting in the new index file showing:
Code: Select all
// Configuration
require_once('config.php');
require_once('config2.php');
a backup is made to "index.php_20100503_config3mod"
Resulting in the final index file showing:
Code: Select all
// Configuration
require_once('config.php');
require_once('config3.php');
require_once('config2.php');
while that would be better than what we have now you would have to uninstall everything in the order you installed it, unless I'm missing something.Qphoria wrote: Then uninstalls would simply replace the newly created file with the backed up version.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
So, I don't think Q's solution would work.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
I had problems with it in SMF and sometimes had to manually build in some of the mods.Qphoria wrote:Well i dunno. it works for SMF and I've never had a problem there.
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
Users browsing this forum: No registered users and 31 guests