Pektsekye Posted May 20, 2009 Posted May 20, 2009 Download the latest Autoinstaller script from http://addons.oscommerce.com/info/6765 Place all the new files into the autoinstaller / files directory Open the install.xml file Add the before installation message <step> <action>open_file</action> <filename>... Your filename here ... </filename> </step> <step> <action>add_to_file</action> <code><![CDATA[ ... Your code to add here ... }]]></code> </step> <step> <action>save_file</action> </step> Add steps to open an optional file and add code to the end of it <step> <action>open_file_if_exists</action> <filename>... Your filename here ... </filename> </step> <step> <action>add_to_file</action> <code><![CDATA[ ... Your code to add here ... ]]></code> </step> <step> <action>save_file</action> </step> Add steps to open a file and replace something in it <step> <action>open_file</action> <filename>... Your filename here ... </filename> </step> <step> <action>replace</action> <pattern><![CDATA[... Your pattern here ... ]]></pattern> <replacement><![CDATA[... Your replacment here ... ]]></replacement> <manual_from><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_from> <manual_to><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_to> </step> <step> <action>save_file</action> </step> Add steps to open an optional file and replace something in it <step> <action>open_file_if_exists</action> <filename>... Your filename here ... </filename> </step> <step> <action>replace</action> <pattern><![CDATA[... Your pattern here ... ]]></pattern> <replacement><![CDATA[... Your replacment here ... ]]></replacement> <manual_from><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_from> <manual_to><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_to> </step> <step> <action>replace</action> <pattern><![CDATA[... Your pattern here ... ]]></pattern> <replacement><![CDATA[... Your replacment here ... ]]></replacement> <manual_from><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_from> <manual_to><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_to> </step> <step> <action>replace</action> <pattern><![CDATA[... Your pattern here ... ]]></pattern> <replacement><![CDATA[... Your replacment here ... ]]></replacement> <manual_from><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_from> <manual_to><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_to> </step> <step> <action>save_file</action> </step> As you see the action replace should have: 1) regular expression pattern. Example: <?php ob_start(); ?> .... Your code to be replaced here .... <?php $cont = ob_get_contents(); ob_end_clean(); ob_start(); ?> ... Your replacment here ... <?php $to = ob_get_contents(); ob_end_clean(); $cont = preg_replace(' ... Your pattern here ... ',$to,$cont,-1,$count); echo $cont; echo $count; ?> 3) instructions for manual installation. Example: <manual_from><![CDATA[ $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; ]]></manual_from> <manual_to><![CDATA[ // BOF qpbpp //$select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_qty_blocks, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; // EOF qpbpp ]]></manual_to> 4)(Optional. The default value is 1) the limit how many times the pattern should be replaced <step> <action>open_file</action> <filename>... Your filename here ... </filename> </step> <step> <action>replace</action> <limit>-1</limit> <pattern><![CDATA[... Your pattern here ... ]]></pattern> <replacement><![CDATA[... Your replacment here ... ]]></replacement> <manual_from><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_from> <manual_to><![CDATA[ ... Your instructions for manual installation here ... ]]></manual_to> </step> <step> <action>save_file</action> </step> NOTE: The open_file action save a backup so you must not open the same file twice and you must not forget to save the file after editing. Example: <step> <action>run_query</action> <query><![CDATA[.. Your installation MySql query here ... ]]></query> <unquery>.. Your uninstallation MySql query here ...</unquery> </step> <step> <action>run_query</action> <query><![CDATA[.. Your installation MySql query here ... ]]></query> <unquery>.. Your uninstallation MySql query here ... </unquery> </step> The autoinstaller / backup folder and the uninstall.xml file must always exist with 777 permissions. The autoinstaller script must not do any steps that affects site security. Such as changing the files and folders permissions. Let the user do it manually. Use real contributions with autoinstaller as examples: http://addons.oscommerce.com/info/2900 - FCKeditor for Product Descriptions http://addons.oscommerce.com/info/2823 - Ultimate SEO URLs http://addons.oscommerce.com/info/1242 - Quantity Price Breaks Per Product http://addons.oscommerce.com/info/6740 - Autoinstaller for - One Page Checkout Quote
Pektsekye Posted May 30, 2009 Author Posted May 30, 2009 I can write an extend.php file to make the autoinstaller "Silly" It doesn't mean that it will break your site. It means that it will not use regular expressions. It will try to find the exact chunk of code and replace it with exact chunk of code. + the plus of it is that you don't need to have experience with regular expressions - the minus of it is that the user will have to do more steps manually But it will still do the main part of the work: 1. copy files 2. run database install query 3. replace what he can 4. create backup and make it possible to uninstall with simple click Of course it will work like a charm on "vanilla" install of oscommerce. So it can also be used as "Live demo on your test site just in seconds" Let me know if somebody is interested Stanislav Quote
Jan Zonjee Posted May 31, 2009 Posted May 31, 2009 I'm no good with regular expressions but haven't tried to figure it out really too. Just tried your autoinstaller for SPPC 4.2 on a vanilla install. Very impressive. It took only seconds for installing. I did notice a few new icons weren't there yet and I also notice I should update the admin/customers_groups.php because it doesn't use those new icons (the correct customers_group.php was added to the Hide products for customers for SPPC contribution by the way, among others I think). Just as a side-note for anyone trying this locally on his/her Mac. I had to make the webserver owner of the catalog directory and files in it with (in a terminal window and navigating to /Library/WebServer/Documents first): sudo chown -R _www catalog (and then type in my password in the popup window of course). After installing I changed it back (same code, using your Mac username - which you see when you open a terminal window ~ your_user_name$ - instead of _www) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.