Page 4 of 35

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Tue Jan 04, 2011 8:48 am
by JNeuhoff
I have created and tested some vqmod XML files for:

- Export / Import module
- Customer Testimonials Package

Each of these Opencart addons modifies the Opencart core files

admin/controller/common/header.php
admin/language/english/common/header.php
admin/view/template/common/header.tpl

and it works just fine!

Great tool! 8)

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Tue Jan 04, 2011 9:43 am
by Qphoria
Excellent to hear :)

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Tue Jan 04, 2011 12:21 pm
by kedgetech
Excellent work Q. Would save us a ton of time.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Tue Jan 04, 2011 1:25 pm
by Qphoria
Should have the xml generator form done this week to make it even easier to make vqmod .xml files

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 5:33 am
by JNeuhoff
The logging still seems to have problems:

When I turn it on, e.g. via a

Code: Select all

$vqmod->logging = TRUE;
It will only create log entries when processing the vqmod/vqmod_opencart.xml , not for any of the other XML files.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 6:21 am
by Qphoria
Actually I'm seeing in some cases when logging is FALSE that this happens. It happens on my linux box but not on my windows box. It is weird.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 6:27 am
by JNeuhoff
I am trying to add another function to catalog/controller/product/category.php, like this:

Code: Select all

.....
	<file name="catalog/controller/product/category.php">
		<operation>
			<search position="before"><![CDATA[}
?>]]></search>
			<add><![CDATA[
	private function startsWith( $haystack, $needle ) {
		if (strlen( $haystack ) < strlen( $needle )) {
			return FALSE;
		}
		return (substr( $haystack, 0, strlen($needle) ) == $needle);
	}
			]]></add>
		</operation>
	</file>
......
It won't do it, nor does it log an error message.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 6:36 am
by Qphoria
JNeuhoff wrote:Another bug:

I am trying to add another function to catalog/controller/product/category.php, like this:

Code: Select all

<search position="before"><![CDATA[}
?>]]></search>
It won't do it, nor does it log an error message.
You appear to be using a multiline search. I assume you are trying to match:

Code: Select all

    }
?>
You can't do multiline searches.

You will need to use the offset feature. You can do it a few different ways, but since it looks like its the end of the file, try:
<search position="bottom" offset="1"></search>

you can leave the contents blank as bottom assumes the last line of the file, and offset means go up 1 line and add the code before that line.

I will see about improving the logging for that.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 6:45 am
by JNeuhoff
Using the offset attribute solved the problem. it is now working:

Code: Select all

....
	<file name="catalog/controller/product/category.php">
		<operation>
			<search position="bottom" offset="2"></search>
			<add><![CDATA[
	private function startsWith( $haystack, $needle ) {
		if (strlen( $haystack ) < strlen( $needle )) {
			return FALSE;
		}
		return (substr( $haystack, 0, strlen($needle) ) == $needle);
	}
			]]></add>
		</operation>
	</file>
.....
Thanks a lot.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 10:55 am
by Xsecrets
I just found it easiest to search for the class line and add it after since it really doesn't matter what order the functions are in.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Wed Jan 05, 2011 11:01 am
by Qphoria
Yea. Its nice that there are so many different ways to mod it.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Thu Jan 06, 2011 7:40 pm
by JNeuhoff
Is there an ability to replace multiple lines by some added code?

May be something like in the following example:

Code: Select all

<operation>
	<search position="replace" offset="1" range="5"><![CDATA[public function xyz() {]]></search>
	<add><![CDATA[
	..... replacement lines ...
	]]></add>
</operation>
- Search for the line containing 'public function xyz() {'.
- Replace the following 5 lines with some new code.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Thu Jan 06, 2011 8:45 pm
by Qphoria
JNeuhoff wrote:Is there an ability to replace multiple lines by some added code?

May be something like in the following example:

Code: Select all

<operation>
	<search position="replace" offset="1" range="5"><![CDATA[public function xyz() {]]></search>
	<add><![CDATA[
	..... replacement lines ...
	]]></add>
</operation>
- Search for the line containing 'public function xyz() {'.
- Replace the following 5 lines with some new code.
This is already part of the replace offset ability.
I do this here:
http://forum.opencart.com/viewtopic.php ... 48#p123509

Take a look at this example:
I want to replace:

Code: Select all

public function query($sql) {
        return $this->driver->query($sql);
} 
with:

Code: Select all

public function query($sql) {
        $result = $this->driver->query($sql);
        $exec_time = (time() + microtime());
        $exec_time = round($exec_time - $query_time, 4);
        $_SESSION['query_total_time'] += $exec_time;
}
So I would use

Code: Select all

<search position="replace" offset="2"><![CDATA[
public function query($sql) {
]]></search>
This finds the first line of that function.... then removes that line plus the next 2 lines from the offset.
Then inserts the new code at the originally replaced line. The replace is handled differently in the code where the offset works as a range delete, and then new code is added in place of it

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 3:41 am
by lrombes
Q,

I was looking at the VirualQMod_Readme file and in the second paragraph it says to drop files in the /vmod/ folder. Is this correct or should it be /vqmod/? version 1.0.5.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 3:54 am
by Qphoria
vqmod.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 6:09 am
by JNeuhoff
This finds the first line of that function.... then removes that line plus the next 2 lines from the offset.
Then inserts the new code at the originally replaced line. The replace is handled differently in the code where the offset works as a range delete, and then new code is added in place of it
Thanks, good to know it can be done.

I am in the process of switching my own website to the Opencart framework, and the VQMod comes in quite handy. I installed several modules which were modifying some of the same Opencart core files, and with a few tweaks in the category.php / category.tpl specified in the VQMod XML file I can also use the system as a simple CMS. Upgrading the system to future releases of Opencart will now be a lot easier!

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 6:49 am
by Qphoria
Hurrah! I now have 32 mods on my live site using vqmod. Ive been including vqmod options with all my latest mod updates that require core modifications. I only use vqmod now for modifications.

Ive got the xml generator almost done. Just adding the jquery for adding multiple files and operations. That should make it even easier to make then.

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 9:32 am
by marc_cole
Looking forward to it! Will we be able to modify CSS stylesheets anytime soon with VQMod?

BTW, you've got me beat. I only have 15 mods. :'(

Marc

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 9:35 am
by Qphoria
marc_cole wrote:Will we be able to modify CSS stylesheets anytime soon with VQMod?
VQMod is limited to what passes through the php engine. Stylesheets are simply passed through and rendered directly from the browser so you can't change those. But you can change the tpl file that calls the stylesheet. So if you make your own stylesheet, you modify the
<link rel="stylesheet" src="xxxxxxx">
line in the tpl

Re: [MOD] - VirtualQMod - Virtual Modification System

Posted: Sat Jan 08, 2011 10:30 pm
by JNeuhoff
There is still the some issue of not doing the logging correctly.

I have an XML file where it ignores an <operation> , probably due to some unknown error, yet it doesn't log anything, making it hard to track down the error cause.