Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Contrib Installer


rinon

Recommended Posts

i also noticed that when i went to the contrib_installer.php it gives me the following error

Parse error: parse error, unexpected T_ELSEIF in /home/airsoft1/public_html/admin/includes/functions/html_output.php on line 21
and the code from 18-23 is:

    /* End Admin_Access-2.1.1 - installed by contrib_installer */
   if ($connection == 'NONSSL') {
     $link = HTTP_SERVER . DIR_WS_ADMIN;
   /* End Admin_Access-2.1.1 - installed by contrib_installer */ elseif ($connection == 'SSL') {
     if (ENABLE_SSL == 'true') {
       $link = HTTPS_SERVER . DIR_WS_ADMIN;

 

line 21 is " /* End Admin_Access-2.1.1 - installed by contrib_installer */ elseif ($connection == 'SSL') { "

Edited by EvaD
Link to comment
Share on other sites

  • Replies 430
  • Created
  • Last Reply

Top Posters In This Topic

i also noticed that when i went to the contrib_installer.php it gives me the following error and the code from 18-23 is:

 ? ?/* End Admin_Access-2.1.1 - installed by contrib_installer */
? ?if ($connection == 'NONSSL') {
? ? ?$link = HTTP_SERVER . DIR_WS_ADMIN;
? ?/* End Admin_Access-2.1.1 - installed by contrib_installer */ elseif ($connection == 'SSL') {
? ? ?if (ENABLE_SSL == 'true') {
? ? ? ?$link = HTTPS_SERVER . DIR_WS_ADMIN;

 

line 21 is "  /* End Admin_Access-2.1.1 - installed by contrib_installer */ elseif ($connection == 'SSL') { "

 

Contrib Installer is pasting itself in the middle of code, sometimes removing code completely. The only package I have had work is the PayPal IPN install.

Link to comment
Share on other sites

Contrib Installer is pasting itself in the middle of code, sometimes removing code completely. The only package I have had work is the PayPal IPN install.

 

Yes, that seems to be the problem with it. Sorry everyone for all the trouble. I'm on vacation till saturday, so I can't work on this until I get back.

 

It seems to be related to PHP4 vs. PHP5. I have everything running on 5, but when I get back I'm going to try to install and test this on 4.

 

- Rinon

Link to comment
Share on other sites

Hey rinon,

 

This Contribution should be great once i have it running howvere, i was hoping you can shead some light on my issue.

 

I downloaded the latest version of Contrib Installer, posted on 10 Aug 2005,

 

 

 

I browse to http://www.doming.com/admin/contrib_installer.php where it displays the "Initialize Contrib Installer page".

 

In the "Contribution Directory" it displays "/home/httpd/vhosts/domain.com/admin/contributions",

 

When i hit "Continue" i get the following Error message,

 

"I need write permission for: /home/httpd/vhosts/domain.com/admin/contributions"

 

I have tried to allow write permissions on the admin folder but without any luck..

I even tried to allow write permissions on everysingle files to see if that would work..

 

 

What do you think could be the issue?

 

Thanks

Chris

Director

ProPowders.com.au

Your Online Health Supplement Store

Link to comment
Share on other sites

Hey rinon,

 

This Contribution should be great once i have it running howvere, i was hoping you can shead some light on my issue.

 

I downloaded the latest version of Contrib Installer, posted on 10 Aug 2005,

I browse to http://www.doming.com/admin/contrib_installer.php where it displays the "Initialize Contrib Installer page".

 

In the "Contribution Directory" it displays  "/home/httpd/vhosts/domain.com/admin/contributions",

 

When i hit "Continue" i get the following Error message,

 

"I need write permission for: /home/httpd/vhosts/domain.com/admin/contributions"

 

I have tried to allow write permissions on the admin folder but without any luck..

I even tried to allow write permissions on everysingle files to see if that would work..

What do you think could be the issue?

 

Thanks

 

You will need to manually create a directory to store CIPs in. I would suggest using the default, so create a directory called contributions in the admin/ folder.

 

- Rinon

Link to comment
Share on other sites

thanks for your reply..

i had already created a new dicectore in the admin folder called "contributions"

 

and ive set full permissions on the folder..

Hmmm strange

 

Which version of PHP are you using (you can find this under server info in the Tools section of the Admin interface)? The installer (at least for the moment) requires at least PHP 4.

 

I did find a few mistakes in the code, which may be the cause of your problem:

 

Line 75:

  if(!is_writable(dirname($contrib_dir)) && !is_dir(dirname($contrib_dir)))

should be:

  if(!is_writable(dirname($contrib_dir)) && !is_dir($contrib_dir))

 

And line 86:

  if(!is_dir(dirname($contrib_dir)))

should be:

  if(!is_dir($contrib_dir))

 

I will fix these in the next release.

 

- Rinon

Link to comment
Share on other sites

Sorry if this question was asked before (really I looked)

 

How does it know what was deleted and what wasn't and if a contribution looks for something that was changed by another contribution what happens

I read part of the script and so far this is what I see might happen

//////////////////////

 

if there are 3 contributions (made for CI)

contrib1 instalation (installs succesfully in new MS2)

--find in fileX tep_something($something) line 200 change to

if(tep_something($something))

do this;

else do that:

 

contrib2 instalation

--change in fileX tep_something($something) line 200 to

if((something_here) && tep_something($something))

do this too;

else do that too;

 

contribution 3 instalation

--delete in fileX tep_something($something) line 200

 

but tep_something($something) was changed by contrib 1 so contribution 2 and 3 will leave file x line 200 looking like this

 

if(if((something_here) && )

do this too;

else do that too;)

do this;

else do that:

 

/////////////////////////

 

or does something else happen

Edited by crashwave

q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| )

Link to comment
Share on other sites

Sorry if this question was asked before (really I looked)

 

How does it know what was deleted and what wasn't and if a contribution looks for something that was changed by another contribution what happens

I read part of the script and so far this is what I see might happen

//////////////////////

 

if there are 3 contributions (made for CI)

contrib1 instalation (installs succesfully in new MS2)

  --find in fileX tep_something($something) line 200 change to

if(tep_something($something))

do this;

else do that:

 

contrib2 instalation

  --change in fileX  tep_something($something) line 200 to

if((something_here) && tep_something($something))

do this too;

else do that too;

 

contribution 3 instalation

  --delete in fileX  tep_something($something) line 200

 

  but tep_something($something) was changed by contrib 1 so contribution 2 and 3 will leave file x line 200 looking like this

 

if(if((something_here) && )

do this too;

else do that too;)

do this;

else do that:

 

/////////////////////////

 

or does something else happen

 

What is supposed to happen (this part seems to be working ok) is that CI keeps track of which lines it has changed. When it goes to install a new contrib, it checks this table, and if it has already changed something on the line that this new contrib needs, it throws a conflict error.

 

The danger in this comes when you alter files manually, since these changes are not tracked in the CI table.

 

- Rinon

Link to comment
Share on other sites

hello rinon

is there a guideline to write contribution that works with your installer

 

I don't have any official guides to making a CIP (Contrib Installer Package), but I did try to comment my sample CIP as much as possible. Try looking at the files in the "example contribution" folder in the zip file, especially the install.xml file. This should get you started with making a package. If anyone needs any more details/help making CIPs, just let me know, I'd be happy to help.

 

- Rinon

Link to comment
Share on other sites

In both of these cases, it would seem to me that the correct database entry doesn't exist. Can you see if there is any database entry in the configuration table referrring to MODULE_CONTRIB_INSTALLER_DIR_FS_CONTRIBUTIONS? Perhaps this SQL would work for you:

SELECT * FROM configuration WHERE configuration_key = 'MODULE_CONTRIB_INSTALLER_DIR_FS_CONTRIBUTIONS';

 

- Rinon

 

I have the same problem :

 

Warning: opendir(c:\program files\easyphp1-8\www\contributions\): failed to open dir: Invalid argument in c:\program files\easyphp1-8\www\oscommerce\admin\contrib_installer.php on line 832

 

Warning: readdir(): supplied argument is not a valid Directory resource in c:\program files\easyphp1-8\www\oscommerce\admin\contrib_installer.php on line 833

 

Warning: closedir(): supplied argument is not a valid Directory resource in c:\program files\easyphp1-8\www\oscommerce\admin\contrib_installer.php on line 838

 

 

I checked the database entry but the entry is there!

Link to comment
Share on other sites

Rinon, unless I'm doing something wrong, the download for v0.4 is missing a key file that has completely made a mess of my attempt to install your contribution. All that I see in the archive is a total of seven individual files:

 

/catalog/admin/contrib_installer.php

/catalog/admin/includes/functions/xml_parser.php

/catalog/admin/includes/languages/english/images/buttons/ (5 .gifs)

 

However, since I haven't been able to get it to work right after about 5 tries, I looked at your uninstall information, which talks about removing the file:

 

admin/includes/languages/english/contrib_installer.php

 

This was not included in your package. Have I done something wrong?

 

Thanks!

Link to comment
Share on other sites

Rinon, unless I'm doing something wrong, the download for v0.4 is missing a key file that has completely made a mess of my attempt to install your contribution.  All that I see in the archive is a total of seven individual files:

 

/catalog/admin/contrib_installer.php

/catalog/admin/includes/functions/xml_parser.php

/catalog/admin/includes/languages/english/images/buttons/ (5 .gifs)

 

However, since I haven't been able to get it to work right after about 5 tries, I looked at your uninstall information, which talks about removing the file:

 

admin/includes/languages/english/contrib_installer.php

 

This was not included in your package.  Have I done something wrong?

 

Thanks!

 

Ah, yes the language file. No, I actually didn't forget it, although thanks for pointing this out. This file is created by the script during the initialization of the Installer (the first time it's run, after you put in the contrib directory). If it doesn't exist after this initialization, then something has gone wrong. Please let me know if this happens, that would be yet another bug that I can't duplicate :( .

 

Hope that answers your question.

 

- Rinon

Link to comment
Share on other sites

I wish This was out way before any contributions would have made everybody's life easier...

But with all the contributions and modifications done there is no way this will work for people that have a modified script. :(

Unless we change the contibutions we want to add to OUR modified version.

Anyway Rinon GREAT JOB :thumbsup:

Maybe osc can add this someway to A release. I think the new version is pretty much done. Speaking of where can someone get a copy. I've seen it run as demos on some sites..admin section looks pretty cool B)

Edited by crashwave

q_|_|| _|9~~J >-o>-o q_|_|| )| q_|| )

Link to comment
Share on other sites

Hi,

 

You have a wonderful idea here. I am just getting up to speed with osCommerce. Although after spending the last couple of months working with phpBB it is somewhat dissapointing that osCommerce is so immature with the way they handle mods as compared to phpBB. Hopefully it will come around soon.

 

Contribution Installer is a singificant step forward in that maturity. I have a suggestion AND a problem. First the suggestion.

 

I would highly suggest that instead of maintaining a separate source for contributions converted to Contribution Installer that we all work with the original person or group who developed the contribution and place the xml on their contribution page. And then try to convince them to use the xml format. The XML is a better document to use for manual updates anyway, and then it would be there for those using the automated process. I am working with converting my first contribution at the moment. I plan to place it back on the original contribution page and contact the developer of that contrib.

 

Now, my problem...

 

I have already run into the problem with the way php xml handles entities such as   and converted those instances to the numeric equilivent. Now I have run into several php coding operands that cause the XML to fail. One in particular is the AND (&&). If the XML can't handle the full php language this will not be successfull. I seriously doubt this will be accepted if you have to ask someone to make ANY changes to their code just to accomodate the installer. What is the solution for this?

 

Here is the portion of the install.xml that is failing with "not well formed":

 

(This fails at the first &&)

 

<findreplace>
 <file name="catalog/includes/modules/product_listing.php" />
 <find>
  	 case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
           } else {
             $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
           }
           break;
   </find>
   <replace>
    	 // *****************************************
    	 // begin: CallForPrice contribution ref#8579
    	 // *****************************************
    	 case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
           } elseif (CALL_FOR_PRICE_AMT > -1 && $listing['products_price'] == CALL_FOR_PRICE_AMT) {
             $lc_text = TEXT_CALL_FOR_PRICE;
           } else {
             $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
           }
           break;
         // *****************************************
    	 // end: CallForPrice contribution ref#8579
    	 // *****************************************
   </replace>
</findreplace>

Link to comment
Share on other sites

I would highly suggest that instead of maintaining a separate source for contributions converted to Contribution Installer that we all work with the original person or group who developed the contribution and place the xml on their contribution page.  And then try to convince them to use the xml format.  The XML is a better document to use for manual updates anyway, and then it would be there for those using the automated process.  I am working with converting my first contribution at the moment.  I plan to place it back on the original contribution page and contact the developer of that contrib.

Unfortunately I have been asked by the devel team to place all install packages on the Contrib Installer page. I was going to put the CIPs on their respective contrib pages, as I think this is a more logical arrangement, but any future CIPs should go on the Contrib Installer page (I'm not sure what they want done with CIPs that you make for your own contribs).

 

 

Now, my problem...

 

I have already run into the problem with the way php xml handles entities such as   and converted those instances to the numeric equilivent.  Now I have run into several php coding operands that cause the XML to fail.  One in particular is the AND (&&).  If the XML can't handle the full php language this will not be successfull.  I seriously doubt this will be accepted if you have to ask someone to make ANY changes to their code just to accomodate the installer.  What is the solution for this? 

 

Here is the portion of the install.xml that is failing with "not well formed":

 

(This fails at the first &&)

Real easy solution to this problem. Enclose any code that may cause well-formedness errors between "<![CDATA[" and "]]>" (without quotes). This causes parsers to see the stuff in between as raw text, without any possibility of being XML.

 

Let me know how you do converting your contrib to a CIP (contrib installer package), and if you need any assistance.

 

- Rinon

Link to comment
Share on other sites

I am making progress with my mod. It is recognizing the XML file now as valid. However, I am getting an error message. There is not enough detail to be able to determine what is wrong. I would HIGHLY suggest as a useability measure to improve the error messages. When it finds something wrong it should give an exact message. Otherwise people will get too frustrated with the package to use it.

 

The message I am getting is: Invalid config file. Error in findreplace section #1

 

I'm sure there are a ton of reasons this could happen. The question is, how do I determine which it is?

 

Here is the first findreplace section:

 

<findreplace>
   <file name="includes/modules/product_listing.php" />
   <find><![CDATA[
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
           } else {
             $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
           }
           break;
   ]]></find>
   <replace><![CDATA[
         // *****************************************
         // begin: CallForPrice contribution ref#8579
         // *****************************************
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           if (tep_not_null($listing['specials_new_products_price'])) {
             $lc_text = '?<s>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s>??<span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>?';
           } elseif (CALL_FOR_PRICE_AMT > -1 && $listing['products_price'] == CALL_FOR_PRICE_AMT) {
             $lc_text = TEXT_CALL_FOR_PRICE;
           } else {
             $lc_text = '?' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '?';
           }
           break;
         // *****************************************
         // end: CallForPrice contribution ref#8579
         // *****************************************
   ]]></replace>
   <find><![CDATA[
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
           break;
   ]]></find>
   <replace><![CDATA[
         // *****************************************
         // begin: CallForPrice contribution ref#8579
         // *****************************************
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           if (CALL_FOR_PRICE_AMT > -1 && $listing['products_price'] == CALL_FOR_PRICE_AMT)
           {
             $lc_text = '?';
           } else {
            $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?';
           }
           break;
         // *****************************************
         // end: CallForPrice contribution ref#8579
         // *****************************************
   ]]></replace>
 </findreplace>

Link to comment
Share on other sites

I am making progress with my mod.  It is recognizing the XML file now as valid.  However, I am getting an error message.  There is not enough detail to be able to determine what is wrong.  I would HIGHLY suggest as a useability measure to improve the error messages.  When it finds something wrong it should give an exact message.  Otherwise people will get too frustrated with the package to use it.

 

OK.. I am trying to make a little more sense of the example. It is difficult without more detailed instructions.

 

It appears I have to put the code in the <find> parameter and still put in line numbers effected in the <originallinenumbers> parm. Is that true? If I specify the exact code to the replaced why do I have to put in the line numbers? As I examine the code and the example I think I may have answered my own question here. Please correct me if I am wrong. But you are using the original code as the base. Since multiple contribs may effect a module it is up to the developer of the contrib to keep up with the original code that is effected. Then the installer can monitor conflicts. If that is an accurate statement how does it work with contribs that modify other contribs? What do you put in the line number fields then?

 

So I suppose the question is, how do I properly code a findreplace?

 

Now that I look closer it appears the format is:

 

<findreplace>
   <file name="relative/path/from/install/a_pgm.php" />
   <find>Text to find in the file</find>
   <replace>New text to put in file</replace>
   <originallinenumbers start="X" end="Y" />
</findreplace>

 

The question I would have here is what actually goes in the <find> parameter? Just the first line in the block of code I want to replace? Or the entire block?

 

What I was trying to do is come up with a model for others to easily use. With a big issue that PHP coding can cause a problem with XML validation. So I am trying to put the <![CDATA[ and ]] as a regular part of the XML and always go to separate lines for code for ease of use. Which turns my example into:

 

<findreplace>
   <file name="relative/path/from/install/a_pgm.php" />
   <find><![CDATA[
       Text to find in the file
   ]]</find>
   <replace><![CDATA[
       New text to put in file
   ]]</replace>
   <originallinenumbers start="X" end="Y" />
</findreplace>

 

If the two examples will work the same then I would recommend the second as a general guideline so a person wouldn't have to start worrying about where they really need to put the CDATA block.

 

If this is the case then what I left out in my mod was the line numbers. Does that sound right?

 

And a last question for now concerning addcode. Since I am inserting after a specific line why would the start and end line numbers ever be different?

 

Sorry for all the confusion and questions. I am just trying to get a good solid understanding of the process. I will be going through the php itself to get a better idea of how it processes the XML but your answers will help even more.

 

Thanks,

 

Glenn

Link to comment
Share on other sites

OK.. I am trying to make a little more sense of the example.  It is difficult without more detailed instructions.

Sorry, I haven't even had time to get the bugs out of the installer code :( . Hopefully I (or someone else) can eventually write better documentation.

It appears I have to put the code in the <find> parameter and still put in line numbers effected in the <originallinenumbers> parm.  Is that true?  If I specify the exact code to the replaced why do I have to put in the line numbers?  As I examine the code and the example I think I may have answered my own question here.  Please correct me if I am wrong.  But you are using the original code as the base.  Since multiple contribs may effect a module it is up to the developer of the contrib to keep up with the original code that is effected.  Then the installer can monitor conflicts.  If that is an accurate statement how does it work with contribs that modify other contribs?  What do you put in the line number fields then?

The <originallinenumbers> is used to make sure that the code in the <find> section (which should be, for most contribs, part of the base osCommerce) has not been changed by another CIP.

So I suppose the question is, how do I properly code a findreplace?

 

Now that I look closer it appears the format is:

 

<findreplace>
? ?<file name="relative/path/from/install/a_pgm.php" />
? ?<find>Text to find in the file</find>
? ?<replace>New text to put in file</replace>
? ?<originallinenumbers start="X" end="Y" />
</findreplace>

That's right except for one major thing: The name parameter in the <file> should be the relative path from the catalog/ directory, not that of the install program.

The question I would have here is what actually goes in the <find> parameter? Just the first line in the block of code I want to replace?  Or the entire block?

It should be everything you want replaced.

What I was trying to do is come up with a model for others to easily use.  With a big issue that PHP coding can cause a problem with XML validation.  So I am trying to put the <![CDATA[ and ]] as a regular part of the XML and always go to separate lines for code for ease of use.  Which turns my example into:

 

<findreplace>
? ?<file name="relative/path/from/install/a_pgm.php" />
? ?<find><![CDATA[
? ? ? ?Text to find in the file
? ?]]</find>
? ?<replace><![CDATA[
? ? ? ?New text to put in file
? ?]]</replace>
? ?<originallinenumbers start="X" end="Y" />
</findreplace>

 

If the two examples will work the same then I would recommend the second as a general guideline so a person wouldn't have to start worrying about where they really need to put the CDATA block.

Yes, these are functionally the same (again, the relative path should be from the catalog/ directory). Putting the CDATA tags can never hurt anything, so you're right, you might as well always put them in.

If this is the case then what I left out in my mod was the line numbers.  Does that sound right?

Exactly

And a last question for now concerning addcode.  Since I am inserting after a specific line why would the start and end line numbers ever be different?

I've found instances where you may need to search for multiple lines in the <find> section. For example the line directly before where you want to insert the text occurs 5 times in the file, but you want it inserted after the third one. In that case you would have to include multiple lines in the <find> part so that you have a unique block of code.

Sorry for all the confusion and questions.  I am just trying to get a good solid understanding of the process.  I will be going through the php itself to get a better idea of how it processes the XML but your answers will help even more.

 

Thanks,

 

Glenn

No problem, please keep the questions coming. They are very usefull for me to know what needs to be improved or documented.

 

- Rinon

Link to comment
Share on other sites

Thank you very much for the information. I think I am starting to get the hang of it now.

 

If I have the time I don't have a problem trying to help put together a quick guide for people to use. It would go a long way in helping to spread the use of the tool.

 

I want to clear up one or two more items quickly.

 

First, I installed osCommerce in directory "/www/mystore/" which is the root used in the webserver. I did not include the "catalog/" directory because I didn't want my user to have to use that in the URL. The way it is configured when they use http://www.mystore.com it points to /www/mystore/. Therefore in my CIP I had assumed the file name only has to use the directory under /www/mystore. So if I want to update /www/mystore/includes/modules/new_products.php my file parm will be coded: <file name="includes/modules/new_products.php" />. Is this correct? Or do I have to use <file name="/www/mystore/includes/modules/new_products.php" />.

 

Second. I want to do multiple replaces in a single findreplace. Although the example doesn't have that in it I have made the assumption that you can. This is structure I have assumed the mod would take. The findreplace would first have the file, followed by a find, then the replace and the originallinenumbers. Then another find, replace and originallinenumbers. And so on... The second originallinenumbers would use the "type=continued" parameter. So my update would be:

 

<findreplace>
   <file name="/appropriate/path/fname.php" />
   <find><![CDATA[
       text I want to change
   ]]</find>
   <replace><![CDATA[
       next text
       with multiple lines
   ]]</replace>
   <originallinenumbers start="16" end="16" />
   <find><![CDATA[
       next text I want to change
       this has multiple lines on the original file
       with all sorts of data and code
   ]]</find>
   <replace><![CDATA[
       maybe I'll replace with one line
   ]]</replace>
   <originallinenumbers start="29" end="31" type="continued" />
</findreplace>

 

Am I close now? (This is the format I am working on right now. But haven't tried to implement yet.)

 

Glenn

Link to comment
Share on other sites

Thank you very much for the information.  I think I am starting to get the hang of it now.

 

If I have the time I don't have a problem trying to help put together a quick guide for people to use.  It would go a long way in helping to spread the use of the tool.

 

I want to clear up one or two more items quickly.

 

First, I installed osCommerce in directory "/www/mystore/" which is the root used in the webserver.  I did not include the "catalog/" directory because I didn't want my user to have to use that in the URL.  The way it is configured when they use http://www.mystore.com it points to /www/mystore/.  Therefore in my CIP I had assumed the file name only has to use the directory under /www/mystore.  So if I want to update /www/mystore/includes/modules/new_products.php my file parm will be coded:  <file name="includes/modules/new_products.php" />.  Is this correct?  Or do I have to use <file name="/www/mystore/includes/modules/new_products.php" />. 

<file name="includes/modules/new_products.php" /> would be correct

Second.  I want to do multiple replaces in a single findreplace.  Although the example doesn't have that in it I have made the assumption that you can.  This is structure I have assumed the mod would take.  The findreplace would first have the file, followed by a find, then the replace and the originallinenumbers.  Then another find, replace and originallinenumbers.  And so on... The second originallinenumbers would use the "type=continued" parameter.  So my update would be:

 

<findreplace>
? ?<file name="/appropriate/path/fname.php" />
? ?<find><![CDATA[
? ? ? ?text I want to change
? ?]]</find>
? ?<replace><![CDATA[
? ? ? ?next text
? ? ? ?with multiple lines
? ?]]</replace>
? ?<originallinenumbers start="16" end="16" />
? ?<find><![CDATA[
? ? ? ?next text I want to change
? ? ? ?this has multiple lines on the original file
? ? ? ?with all sorts of data and code
? ?]]</find>
? ?<replace><![CDATA[
? ? ? ?maybe I'll replace with one line
? ?]]</replace>
? ?<originallinenumbers start="29" end="31" type="continued" />
</findreplace>

 

Am I close now?  (This is the format I am working on right now.  But haven't tried to implement yet.)

 

Glenn

 

No, you can't do this. All <findreplace>'s must be in separate sections. The type=continued option was for replacing multiple parts of the same line. I really don't recommend using it, it's very picky about how it works (when it works) and I think there could be some bugs with using it. But anyways here's how it works:

 

Say you have this original code in somefile.php on line 10:

a line with multiple words

 

and you want to replace:

line -> REPLACEMENT1

multiple -> REPLACEMENT2

 

You would do this like so:

<findreplace>
 <file name="somefile.php" />
 <find>line</find>
 <replace>REPLACEMENT1</replace>
 <originallinenumbers start="10" end="10" />
</findreplace>
<findreplace>
 <file name="somefile.php" />
 <find>multiple</find>
 <replace>REPLACEMENT2</replace>
 <originallinenumbers type="continued" />
</findreplace>

In most cases you would never need to do this, but I needed to for the Admin_Access CIP (which I'm still not sure works completely right). My basic problem was that other contribs could add sections like the following to the admin boxes files:

'<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_CATALOG_CATEGORIES_PRODUCTS_ATTRIBUTES . '</a><br>' .

and I needed to replace the parts that aren't all caps with something else, but leave the all caps stuff.

 

Sorry if that was too long-winded. Simply put: Don't use type=continued. It doesn't do what you'd think it would. Other than that I think your format should be fine.

 

- Rinon

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...