Community Forums

[MOD] - VirtualQMod "vQmod" Virtual File Modification System

Community created contributions & mods for OpenCart 1.x

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Mon Jun 13, 2011 9:08 pm

uksitebuilder wrote:I only downloaded it liek 5 hours ago - has it been updated since then ?

hmm no. Does the vqmod.log show any errors? If it hits an error and it isn't set to "skip" then it will revert the entire file to the normal version
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby uksitebuilder » Mon Jun 13, 2011 9:18 pm

there were a couple of skip errors but only on vqmod default scripts
User avatar
uksitebuilder
 
Posts: 5602
Joined: Thu Jun 09, 2011 3:37 pm
Location: United Kindgom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Mon Jun 13, 2011 9:33 pm

And what were the errors . . .
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4632
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby uksitebuilder » Mon Jun 13, 2011 9:37 pm

Code: Select all
2011-06-13 20:56:53.9483870 - SOURCEFILE:  htdocs/opencart/system/engine/controller.php
2011-06-13 20:56:53.9483940 - MODFILE:     htdocs/opencart/vqmod/xml/vqmod_opencart.xml
2011-06-13 20:56:53.9484000 - TEMPFILE:    htdocs/opencart/vqmod/vqcache/vq-system_engine_controller.php
2011-06-13 20:56:53.9487860 -   OPERATION...
2011-06-13 20:56:53.9487950 -     ERROR:     
2011-06-13 20:56:53.9488010 -     SEARCH:     if (file_exists($file)) {
2011-06-13 20:56:53.9488070 -       POSITION: before
2011-06-13 20:56:53.9488130 -       OFFSET:   
2011-06-13 20:56:53.9488180 -       INDEX:   
2011-06-13 20:56:53.9488240 -       REGEX:   
2011-06-13 20:56:53.9488300 -     ADD:        global $vqmod; $file = $vqmod->modCheck($file);
2011-06-13 20:56:53.9490100 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9490680 -   OPERATION...
2011-06-13 20:56:53.9490750 -     ERROR:      skip
2011-06-13 20:56:53.9490810 -     SEARCH:     if (file_exists(DIR_TEMPLATE . $this->template)) {
2011-06-13 20:56:53.9490870 -       POSITION: replace
2011-06-13 20:56:53.9490920 -       OFFSET:   
2011-06-13 20:56:53.9490980 -       INDEX:   
2011-06-13 20:56:53.9491040 -       REGEX:   
2011-06-13 20:56:53.9491090 -     ADD:       
      global $vqmod;
      $file = $vqmod->modCheck(DIR_TEMPLATE . $this->template);
      if (file_exists($file)) {
      
2011-06-13 20:56:53.9492600 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9493170 -   OPERATION...
2011-06-13 20:56:53.9493240 -     ERROR:      skip
2011-06-13 20:56:53.9493300 -     SEARCH:     exit('Error: Could not load template ' . DIR_TEMPLATE . $this->template . '!');
2011-06-13 20:56:53.9493360 -       POSITION: replace
2011-06-13 20:56:53.9493410 -       OFFSET:   
2011-06-13 20:56:53.9493470 -       INDEX:   
2011-06-13 20:56:53.9493530 -       REGEX:   
2011-06-13 20:56:53.9493580 -     ADD:        exit('Error: Could not load template ' . $file . '!');
2011-06-13 20:56:53.9495040 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9495590 -   OPERATION...
2011-06-13 20:56:53.9495660 -     ERROR:      skip
2011-06-13 20:56:53.9495720 -     SEARCH:     require(DIR_TEMPLATE . $this->template);
2011-06-13 20:56:53.9495780 -       POSITION: replace
2011-06-13 20:56:53.9495830 -       OFFSET:   
2011-06-13 20:56:53.9495890 -       INDEX:   
2011-06-13 20:56:53.9495950 -       REGEX:   
2011-06-13 20:56:53.9496000 -     ADD:        require($file);
2011-06-13 20:56:53.9497500 -   OPERATION COMPLETED SUCCESSFULLY!
2011-06-13 20:56:53.9498690 - TEMPFILE UPDATED WITH MODIFIED CODE
2011-06-13 20:56:53.9499090 - SUBSTITUTION COMPLETE!

User avatar
uksitebuilder
 
Posts: 5602
Joined: Thu Jun 09, 2011 3:37 pm
Location: United Kindgom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby uksitebuilder » Mon Jun 13, 2011 9:39 pm

not errors now I look at it, more commands to skip any errors.

I just rtied a really simple xml file and even removed the two that were working in case for some reason there was a limit on the number of xml files

but the following simply created a duplicate of the original too.

Code: Select all
<modification>
   <id>Header Change</id>
   <version>1.0</version>
   <vqmver>1.1.0</vqmver>
   <author>uksb</author>
   <file name="catalog\view\theme\default\template\common\header.tpl">
      <operation>
         <search position="replace"><![CDATA[
<link href="<?php echo $icon; ?>" rel="icon" />
         ]]></search>
         <add trim="true"><![CDATA[
<link rel="shortcut icon" type="image/x-icon" href="<?php echo $icon; ?>" />
         ]]></add>
      </operation>
   </file>
</modification>
User avatar
uksitebuilder
 
Posts: 5602
Joined: Thu Jun 09, 2011 3:37 pm
Location: United Kindgom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby uksitebuilder » Mon Jun 13, 2011 9:51 pm

I think I have figured it out - haven't tested yet, but seems I was copying the file path's from BeyondCompare and instead of forward slashes BC uses backslashes in the file path.

Coincidence, I think not. Will test and advise if it is now working.

Strange though that duplicates of the original files were being created in the cache.
User avatar
uksitebuilder
 
Posts: 5602
Joined: Thu Jun 09, 2011 3:37 pm
Location: United Kindgom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby uksitebuilder » Mon Jun 13, 2011 9:58 pm

Just tested and it is working now. seems it was the backslashes after all!

Apologies.
User avatar
uksitebuilder
 
Posts: 5602
Joined: Thu Jun 09, 2011 3:37 pm
Location: United Kindgom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 12:50 pm

There is a little bug in VQmod 1.1.0. The replace function adds an additional trailing space character to the replacement, as in the following example:

Code: Select all
   <file name="admin/model/catalog/information.php">
      <operation>
         <search position="replace"><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET ]]></search>
         <add><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET meta_description = '".$data['meta_description']."', meta_keywords = '".$data['meta_keywords']."', ]]></add>
      </operation>
   </file>


While it doesn't hurt in above given example, there could be cases where it becomes relevant to have a precice replacement string, as specified in the replacement operation.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Tue Jun 14, 2011 1:41 pm

JNeuhoff wrote:There is a little bug in VQmod 1.1.0. The replace function adds an additional trailing space character to the replacement, as in the following example:

Code: Select all
   <file name="admin/model/catalog/information.php">
      <operation>
         <search position="replace"><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET ]]></search>
         <add><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET meta_description = '".$data['meta_description']."', meta_keywords = '".$data['meta_keywords']."', ]]></add>
      </operation>
   </file>


While it doesn't hurt in above given example, there could be cases where it becomes relevant to have a precice replacement string, as specified in the replacement operation.


That is why there is the trim="true" attribute for <add>
RTFM ;)
No bug
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 2:15 pm

Works with <add trim="true"> though it kind of defeats the purpose of using <![CDATA[ which is supposed to leave the string unchanged.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Tue Jun 14, 2011 2:16 pm

JNeuhoff wrote:Works with <add trim="true"> though it kind of defeats the purpouse of using <![CDATA[ which is supposed to leave the string unchanged.


touche, tho in your example above there IS a space after the comma and before the ]]. If you remove that space does it still add the space?

Thinking about it now, the replace command simply uses "str_replace" so there is no way it could add additional spaces on its own. the trim attribute is usually only needed for before or after positioning as it creates a new line which may include an extra carriage return if another line before it was already a blank line.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 3:43 pm

Qphoria wrote:touche, tho in your example above there IS a space after the comma and before the ]]. If you remove that space does it still add the space?


yes, the space after the comma is there on purpose. If I remove that space, it still adds one after the replacement which it shouldn't. If I keep the space, it ends up with 2 spaces after the replacement instead of the original single one.
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Tue Jun 14, 2011 3:58 pm

Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 4:10 pm

Qphoria wrote:Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.


No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.
Attachments
information.xml.zip
(962 Bytes) Downloaded 43 times
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Tue Jun 14, 2011 4:21 pm

JNeuhoff wrote:
Qphoria wrote:Is it possible that there is an extra space in the original file itself? I know there are a lot of places that have extra tabs and spaces at the end of the in the core. As I said above, the replace command uses the php function "str_replace" so I dont see any way for an extra space to occur.


No, there is only one space after the comma, see attached file which I am working on for one of my opencart-based projects.


FYI, your closing tag is wrong in the .xml file
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 4:28 pm

Sorry, yes, it should have been </modification>.

Howver, the problem is still there with the additional blank.

I looked at your vqmod.php file. By the time it reaches the line at

Code: Select all
                           $filedata[$linenum] = str_replace($search, $add, $filedata[$linenum]);


the blank character is already chopped off. $search contains

"$this->db->query("INSERT INTO " . DB_PREFIX . "information SET"

instead of

"$this->db->query("INSERT INTO " . DB_PREFIX . "information SET "

while the variable $add is correct. I think the $search is wrong because it is set like this in vqmod.php:

Code: Select all
$search    = trim($operation->getElementsByTagName('search')->item(0)->nodeValue);
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby Qphoria » Tue Jun 14, 2011 5:25 pm

yea i saw this too.. because I ALWAYS trim $search.. the reason I always trim search is to offset the way people format their tags... for readability sake I always use:

Code: Select all
<search position="after"><![CDATA[
'ups_status',
]]></search>


Keeping the code separate from the tags. If i didn't trim then it would be searching for
Code: Select all
\n'ups_status',\n


Technically tho you are right that cdata should be the exact string.. but i made it lax.

That said, it would be detrimental for existing mods to have to go back and fix their xml files to follow the strict rules of cdata. Instead it will just have to be lax and keep in mind that you shouldn't try to match trailing spaces. Perhaps I can add an attribute for the search trim="false"
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18197
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 6:09 pm

You could instead remove leading and trailing whitespaces like \n and \r only, e.g.

Code: Select all
$search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue,"\n\r");
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JAY6390 » Tue Jun 14, 2011 6:20 pm

Qphoria wrote:Perhaps I can add an attribute for the search trim="false"

That to me sounds like the ideal solution
ImageImageImage

Better Product SEO URL's - Perfectly structured product links
Better Category SEO URL's - Give subcategories the same SEO keyword
SEO URL's Route Editor - Fix all of your index.php links


Image
User avatar
JAY6390
 
Posts: 4632
Joined: Wed May 26, 2010 3:47 pm
Location: United Kingdom

Re: [MOD] - VirtualQMod "vQmod" Virtual File Modification Sy

Postby JNeuhoff » Tue Jun 14, 2011 6:34 pm

Let's make it a vqmod version 1.1.1 then:




Code: Select all
final class VQMod {
   private $vqversion = '1.1.1';                  // Current version for logging
   ......

               .....
               if ($version < $this->vqversion) {
                  $search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue);
               } else {
                  $search = trim($operation->getElementsByTagName('search')->item(0)->nodeValue,"\n\r");
               }
               .....
J.Neuhoff - MHC Web Design

OpenCart Override Engine (Version 5.3)
allowing addons to override and modify core methods, language files and templates (see also FAQ)
User avatar
JNeuhoff
 
Posts: 2113
Joined: Tue Dec 04, 2007 7:38 pm

PreviousNext

Return to Free Contributions

Who is online

Users browsing this forum: davehollinshead and 7 guests

Hosted by Arvixe Web Hosting