Author Topic: Bug Fix : function PrintIcon() in htmlTools.class.php  (Read 8196 times)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4656
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Bug Fix : function PrintIcon() in htmlTools.class.php
« on: November 25, 2010, 18:05:29 pm »
SEF don't work in PrintIcon() because ($_SERVER,'QUERY_STRING')) ) is empty when you sef the URL
To Fix this in administrator\components\com_virtuemart\classes\htmlTools.class.php
change
Code: [Select]
function PrintIcon( $link='', $use_icon=true, $add_text='' ) {
global $VM_LANG, $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid;
if ( @VM_SHOW_PRINTICON == '1' ) {
if( !$link ) {
$query_string = str_replace( 'only_page=1', 'only_page=0', vmAmpReplace(vmGet($_SERVER,'QUERY_STRING')) );
$link = 'index2.php?'.$query_string.'&pop=1'.(vmIsJoomla('1.5') ? '&tmpl=component' : '');
}

with this
Code: [Select]

function PrintIcon( $addlink='', $use_icon=true, $add_text='' ) {
global $VM_LANG, $mosConfig_live_site, $mosConfig_absolute_path, $cur_template, $Itemid;
if ( @VM_SHOW_PRINTICON == '1' ) {
if (substr($addlink, 0, 10) == "index2.php") {
$link = $addlink ;
} else {
$query_string= "option=com_virtuemart&page={$_SESSION['last_page']}&only_page=1";
if ($_SESSION['last_browse_parameters']['category_id'])  $query_string.= "&category_id={$_SESSION['last_browse_parameters']['category_id']}";
if ($_SESSION['userstate']['product_id']) $query_string.= "&product_id={$_SESSION['userstate']['product_id']}";

$link = 'index2.php?'.$query_string.'&pop=1'.(vmIsJoomla('1.5') ? '&tmpl=component' : '');
$link .= '&'.$addlink ;
}

THe over think to change is the printbutton in components\com_virtuemart\themes\default\templates\pages\account.order_details.tpl.php
line 26 change
Code: [Select]
<?php echo vmCommonHTML::PrintIcon(); ?>to
Code: [Select]
<?php echo vmCommonHTML::PrintIcon('order_id='.$vars["order_id"]); ?>
And Voila !

I have look for fixes, nothing found  in over forums and this is in all Virtuemart 1.1.2 to 1.1.6 and with many Sef converter (artio sef, router.php file, all over ?) if you have Sef active on virtuemart

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #1 on: November 27, 2010, 09:56:15 am »
Thank you, i will have a look at this and include it in 1.1.7 if possible.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4656
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #2 on: November 27, 2010, 14:17:19 pm »
Zanardi,
I made a ROUTER.PHP file that I developed over several months, I can send it to the forum to test. Is a true SEF not just a simple converting.
You can look for the file in french joomla forum http://forum.joomla.fr/showthread.php?123719-SEF-Virtuemart-Francais-Nouvelle-version

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #3 on: January 02, 2011, 15:31:24 pm »
@Electrocity:
regarding your original post, about a SEF fix for PrintIcon, where does exactly "$addlink" come from?

Unless i can have some more info, i cannot include it in the code. Thank you.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4656
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #4 on: February 04, 2011, 03:48:23 am »
Sorry Zanardi a little late ;)

$addlink is the old $link because i use $link later.
It's only to have no confusion on the code, no new value.

klompen

  • Beginner
  • *
  • Posts: 8
    • Museum of Northern Arizona
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #5 on: March 15, 2011, 07:16:22 am »
I see at http://dev.virtuemart.net/issues/201 that this problem has been fixed and is targeted for 1.1.8. As a newbie to VM I'm nervous about implementing a change like this in 1.1.5 (the version which the developer used for our new site). I get the impression from the referenced Bug report that I could just download the file and replace the existing file, but I don't want to do that without some assurance from VM veterans that this is a safe thing to do.

Advice please?

zanardi

  • Contributing Developer
  • Full Member
  • *
  • Posts: 878
    • GiBiLogic
Re: Bug Fix : function PrintIcon() in htmlTools.class.php
« Reply #6 on: March 15, 2011, 11:28:11 am »
@klompen:
instead of downloading the whole new file, you can manually apply the fix as reported here by Electrocity. You should not have any issue, it is quite a simple fix.
--
Francesco (zanardi)
http://extensions.gibilogic.com
@gibilogic on Twitter