Post by marc_cole » Thu Dec 30, 2010 4:39 am

Q,

Is there a way to add code to either the beginning and/or the end of a file without having to do a search?

Something like:

Code: Select all

<search position="start">

Code: Select all

<search position="end">
Or is it already built-in and I missed it?

Thanks,
Marc

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Qphoria » Thu Dec 30, 2010 5:02 am

^^ Added to latest version!

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Thu Dec 30, 2010 12:50 pm

MAJOR UPDATE IN FIRST POST!

v1.0.3 - 2010-Dec-29 - Qphoria@gmail.com
- Overhauled the temp file and debug process to store the modified versions in the vqcache folder
- Added new "index" attribute for <search>
- Added useCache option for reusing cached versions
- Added logging option
- Added top and bottom positions to search for adding at the very top or bottom of a file
- Added XML fileload handler
- Updated the xml field legend
- Added ability to write to the actual source file instead of virtually modding
- Removed old debug mode and replaced with logging
- Improved code performance
- Changed vqdbg to vqcache
- Updated Readme to be more robust
- Moved Opencart specific information to its own "opencart_install.txt" file

This will not break existing xml mod scripts for older versions. They are backwards compatible with the new changes. Just drop in the new vqmod.php file and folders

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Thu Dec 30, 2010 1:53 pm

looks like this is really starting to shape up. If it works well (which it appears to be) it would be very nice to get an admin gui and standardized zip/tgz format so that users could simply browse for the one file they downloaded and install from the admin.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Thu Dec 30, 2010 2:13 pm

Xsecrets wrote:looks like this is really starting to shape up. If it works well (which it appears to be) it would be very nice to get an admin gui and standardized zip/tgz format so that users could simply browse for the one file they downloaded and install from the admin.
VirtualQMod is not an "OpenCart" tool. It was designed to work with ANY platform. Therefore there is no interface, at least not opencart admin-based. I could add a simple upload interface to the script itself that loads when you call it directly, but really mods are just a single .xml file now. There are no zip files to bother with. No folder structures or permissions. Just drop in the .xml file to apply the mod, and remove the .xml file to remove the mod. True plug-n-play with no dependencies. The concept can even be ported with platforms in other programming languages outside of php.

I've already started making it work with phpbb3 and websitebaker, always using the same vqmod.php class file. It is a single class file designed to work with ANY platform. Only the installs will differ between platforms, and that is easily handled with a pre-defined core.xml mod file that I include with the mod. Currently I include the opencart_core.xml and I left a partial phpbb3 core mod in the zip as well. VirtualQMod will go on to be its own site and possibly github project for use with other platforms. That is what makes it not only great for opencart but innovative for programming in general in systems that include multiple controllers and libraries.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SapporoGuy » Thu Dec 30, 2010 5:04 pm

- Updated Readme to be more robust
Hmmm, does it read faster or something? :laugh:


Now, does this do mod on mod on a mod?

What I mean is it aware enough to know that you have several mods going at the same time?

I also would like to see a simple interface to use via the admin.
With the ability to download via other site (ie, a forum or where ever the mods reside).

Does this store the mods in the db?

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by Xsecrets » Thu Dec 30, 2010 9:06 pm

I get that it is not going to be opencart only and as such vqmod won't have a gui however for the purposes of opencart I think it would be nice for it to come bundled with a gui here for our users even if the core product is developed and expanded on another site.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Thu Dec 30, 2010 11:13 pm

SapporoGuy wrote: Now, does this do mod on mod on a mod?

What I mean is it aware enough to know that you have several mods going at the same time?
Yes, readmes are fun when you read them! You can have unlimited files modding the same file, assuming all mods affect a different part of the file, they will all apply to that file. Meaning that if i have, lets say, 5 mods... all of them affect the product page.

Mod1 - Adds sku to the product page
Mod2 - Adds location to the product page
Mod3 - Hides the reviews tab
Mod4 - Adds a universal message under all product images
Mod5 - Changes the product name font color to red

All 5 mods will be made to that file, and any others you add later.
I also would like to see a simple interface to use via the admin.
With the ability to download via other site (ie, a forum or where ever the mods reside).
I suppose a generic VirtualQMod upload module could be created. One with a basic upload field and perhaps a link to download from a master server
Does this store the mods in the db?
No.

VirtualQMod is designed to be an external standalone class.. like dompdf or ckeditor... and made to plugin to platforms

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Thu Dec 30, 2010 11:26 pm

Xsecrets wrote:I get that it is not going to be opencart only and as such vqmod won't have a gui however for the purposes of opencart I think it would be nice for it to come bundled with a gui here for our users even if the core product is developed and expanded on another site.
yes you are right I can make an admin module for uploading files into the \vqmod\ folder. I'll do that

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SapporoGuy » Fri Dec 31, 2010 12:22 am

Qphoria wrote:Being a forum mod has its perks
Good man, straight up and honest :laugh:


@ mods on mods
Sorry, but there are several mods here that mod the same sql queries.
I've moded 1 sql about 4 times now.

@ admin
Good to hear!

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by Qphoria » Fri Dec 31, 2010 1:21 am

SapporoGuy wrote:
@ mods on mods
Sorry, but there are several mods here that mod the same sql queries.
I've moded 1 sql about 4 times now.
Are u explaining mods to me? ;)
Yes you can edit the same query with all 5 mods if you want. It does of course require the mod to be as specific as possible. As with all mods, it comes down to the mod maker to do it right. Look at the included example in the zip file for Randomize_Latest_Products.xml

You see for the query step, I only search and replace
this:

Code: Select all

ORDER BY p.date_added DESC LIMIT " . (int)$limit);
with:

Code: Select all

ORDER BY rand() DESC LIMIT " . (int)$limit);
The rest of the query is untouched. It is important to always minimize the search to just enough to be unique
This lets other mods change other parts of that line without my mod breaking it.

If another mod uses the full line for the search, then it obviously would not match since the p.date_added was replaced with rand(). So it is important for the mod makers to change only the pertinent details.

Realistically I should have done even better on the search and replace above. I should have simply used:

Code: Select all

ORDER BY p.date_added
replaced with:

Code: Select all

ORDER BY rand()
As there is only one spot that ORDER BY p.date_added is found in that file anyway.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by marc_cole » Fri Dec 31, 2010 1:44 am

Code: Select all

	<search> - Can only search one line!
Q,

Just out of curiosity, can I ask why this is? And did it change from the last version? If so, can it be changed back? :-\

What if we need to search for a section of code, like this:

Code: Select all

foreach ($results as $result) {
            if (!$current_path) {
                $new_path = $result['category_id'];
            } else {
                $new_path = $current_path . '_' . $result['category_id'];
            } 
Apparently I could search for the ending } using the 'index' attribute, but that would be a little tedious to manually count them all.

Is there a better way to do what I'm after? Or did I miss it in the read me? ;)

BTW, thanks for adding 'top' and 'bottom'! This is a fantastic mod!!!

Marc

FYI: I tried doing the following search, but it didn't work:

Code: Select all

<search position="after" index="7"><![CDATA[
            }
			]]></search>
I had to put the above PHP code onto one line and search for it that way to get it to work. Please tell me I'm doing it wrong...

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Qphoria » Fri Dec 31, 2010 2:28 am

Search has always been single line. Very difficult to do multiline search actually but im looking into it.

Ill see about the index issue and maybe some alternate options for what you are trying

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Fri Dec 31, 2010 3:33 am

marc_cole wrote: What if we need to search for a section of code, like this:

Code: Select all

foreach ($results as $result) {
            if (!$current_path) {
                $new_path = $result['category_id'];
            } else {
                $new_path = $current_path . '_' . $result['category_id'];
            } 
For that code you show above, why not search for the next line that comes after it which is:

Code: Select all

$output .= '<li>';
That is guaranteed to be unique in that file. Sometimes instead of searching for code and adding after, you can search for different code and add before.

Another though I had was to allow the search to blindly include lines.
Like if you wanted to search:

Code: Select all

if (!$current_path) {
                $new_path = $result['category_id'];
            } else {
                $new_path = $current_path . '_' . $result['category_id'];
            } 
You could do something like:

Code: Select all

<search lines="4">if (!$current_path) {</search>
That means find the search data, and then include the next 4 lines as part of the search.
Just an idea.. but perhaps the first idea above will work for you.

Also I did find a bug with the index="7" thing, the code for that was in the wrong spot. I've fixed it in v1.0.4

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Fri Dec 31, 2010 4:08 am

Qphoria wrote:
Xsecrets wrote:I get that it is not going to be opencart only and as such vqmod won't have a gui however for the purposes of opencart I think it would be nice for it to come bundled with a gui here for our users even if the core product is developed and expanded on another site.
yes you are right I can make an admin module for uploading files into the \vqmod\ folder. I'll do that
I was actually thinking a little more long term with a zip or tgz file for upload, as just being able to upload an xml to the vqmod folder doesn't do you any good if your mod has completely new files. Like I said I was thinking long term it's not anything I was expecting right away.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by marc_cole » Fri Dec 31, 2010 4:10 am

Qphoria wrote:why not search for the next line that comes after it
Hmm... why didn't I think of that??? :-[ Yes — that works.
Qphoria wrote:Another though I had was to allow the search to blindly include lines.
That sounds interesting! Looking forward to the next release.

Thanks again,
Marc

P.S. If you keep up this frantic pace, you'll need to take a vacation here soon! :choke:

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Qphoria » Fri Dec 31, 2010 4:16 am

Xsecrets wrote:I was actually thinking a little more long term with a zip or tgz file for upload, as just being able to upload an xml to the vqmod folder doesn't do you any good if your mod has completely new files. Like I said I was thinking long term it's not anything I was expecting right away.
Not sure what you mean.. sounds like you are looking more into extension and module zip installation for opencart mods that may or may not have a vqmod file with them. That would simply be a function of a generic package installer for opencart which both you and I have in the works. That isn't really related to VirtualQMod. I could certainly unzip a zip file that has the xml zipped inside of it, but virtualqmod isn't going to handle opencart or any other platforms files.

I think if a package installer is created properly, it should be able to take all files from any number of folders and paste them into their corresponding folder. Currently my dev package installer is basic (doesn't keep a table of installed mods and has no uninstall yet) but it does grab ALL files from the package and upload them to the store root preserving directory structure so it should work straight away.

so if your zip has:
/admin
/catalog
/vqmod
/blah

the package installer should take all files from /admin and put them correctly into your root /admin
all from /catalog into your root /catalog
and all from /vqmod and put them into your root /vqmod.
and assuming you wont have a /blah folder, it should create it for you.
marc_cole wrote:
Qphoria wrote:Another though I had was to allow the search to blindly include lines.
That sounds interesting! Looking forward to the next release.
Ok i've added a new attribute called "offset" in the <search> tag.
Example:

if you have this code and want to add something after it:

Code: Select all

if (!$current_path) {
    $new_path = $result['category_id'];
} else {
    $new_path = $current_path . '_' . $result['category_id'];
} 
You can use:
<search position="after" offset="4">if (!$current_path) {</search>
That means it will first find
if (!$current_path) {
Then move down 4 more lines to the closing "}"
Then add the new code after that line.

if you use
<search position="before" offset="1">$new_path = $result['category_id'];</search>
That means it will first find
$new_path = $result['category_id'];
Then move up 1 more line
Then add the code before that line

if you use
<search position="replace" offset="4">if (!$current_path) {</search>
That means it will first find
if (!$current_path) {
Then delete that first line plus the next 4 lines (total of 5 lines)
Then add the new code in place of that code

top and bottom also support the offset.. n number of lines above the bottom or below the top

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Fri Dec 31, 2010 5:21 am

UPDATED VERSION IN FIRST POST:
v1.0.4 - 2010-Dec-30 - Qphoria@gmail.com
- Fixed bug with <search> "index" attribute
- Added "offset" attribute to <search> tag for blind multiline actions
- Added more code checks to ensure xml values are valid

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SapporoGuy » Fri Dec 31, 2010 6:18 am

oops, sorry, have no idea how that came out.
But you did answer my question!

930sc ... because it is fun!


User avatar
Active Member

Posts

Joined
Mon Nov 01, 2010 7:29 pm

Post by marc_cole » Fri Dec 31, 2010 7:43 am

v1.0.4 fixed a problem I was having with the previous version where my mod files for the admin pages were being ignored. However, now my mods for the store front are being ignored where they worked fine before. Here's one that I had working under v1.0.3:

Code: Select all

<modification>
	<id>Do Not Show Main Categories</id>
	<version>1.0b3</version>
	<vqmver>1.0.4</vqmver>
	<author>marc_cole</author>
	<file name="catalog/controller/module/category.php">
		
	<operation error="skip">
		<search position="before" offset="1"><![CDATA[
			$output .= '<li>';
			]]></search>
		<add trim="false"><![CDATA[
			$path = '';
			if (isset($this->request->get['path'])) {
				$path = $this->request->get['path'];
				}
			$cat_array = explode ("_", $path);
			$top_cat_id = $cat_array[0];
			$sub_array = explode ("_", $new_path);
			$sub_path_id = $sub_array[0];
			if ($top_cat_id == $sub_path_id) {
		]]></add>
	</operation>

	<operation error="skip">
		<search position="before" index="2"><![CDATA[
			if ($results) {
			]]></search>
		<add trim="false"><![CDATA[
			}
		]]></add>
	</operation>

	</file>
</modification>
Perhaps you can see if I'm doing something wrong or if there is a problem with v1.0.4.

Thanks,
Marc

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA
Who is online

Users browsing this forum: No registered users and 43 guests