Forums / All Other Contributions/Addons / IH and zen lightbox and zoom addons clash on edits to same file

IH and zen lightbox and zoom addons clash on edits to same file

Started by abs007 on 9 Feb 2010, 1:40 PM · Views: 2,223

Results 1 to 5 of 5
9 Feb 2010, 1:40 PM
#1
abs007 avatar

abs007

Zen Follower

Join Date:
Mar 2009
Location:
Peterborough UK
Posts:
330
Plugin Contributions:
0

IH and zen lightbox and zoom addons clash on edits to same file

Hi All
I added the zen lightbox to my site and its working fine along with image handler 2. I would also like to add a zoom addon however they are both using a

includes>templates>MYTEMPLATE>templates>tpl_modules_main_product_image.php

anyone know how I can get these 2 to work alongside each other?

thanks

9 Feb 2010, 6:08 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: IH and zen lightbox and zoom addons clash on edits to same file

You can't have two copies of the same file, so you'll need to compare the two with a stock copy of that file and see what they've each changed, then figure out how to merge one's changes into the other (if possible).

I use a program called Compare It!, and a lot of people here use WinMerge.

9 Feb 2010, 6:47 PM
#3
abs007 avatar

abs007

Zen Follower

Join Date:
Mar 2009
Location:
Peterborough UK
Posts:
330
Plugin Contributions:
0

Re: IH and zen lightbox and zoom addons clash on edits to same file

Hi
I have downloaded winmerge and compared the files.

There are so many php queries that I aint got a clue what i will be doing.

Its the first time i have used winmerge so im not sure if I can press a button and it will merge the files together.

If it cant then I guess im stuck as ive tried figuring the code out but no joy

any help would be appreciated. I have tried to search for threads but can not find one

Just incase you wanted to see the 2 files then they are below

Lightbox =

<?php
/**
 * Module Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2005 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_modules_main_product_image.php 3208 2006-03-19 16:48:57Z birdbrain $
 */
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<?php // bof Zen Lightbox 2008-12-15 aclarke ?>
<?php
if (ZEN_LIGHTBOX_STATUS == 'true') {
  if (ZEN_LIGHTBOX_GALLERY_MODE == 'true' && ZEN_LIGHTBOX_GALLERY_MAIN_IMAGE == 'true') {
    $rel = 'lightbox-g';
  } else {
    $rel = 'lightbox';
  }
?>
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="' . zen_lightbox($products_image_large, addslashes($products_name), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT) . '" rel="' . $rel . '" title="' . addslashes($products_name) . '">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
//--></script>
<?php } else { ?>
<?php // eof Zen Lightbox 2008-12-15 aclarke ?>
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
//--></script>
<?php // bof Zen Lightbox 2008-12-15 aclarke ?>
<?php } ?>
<?php // eof Zen Lightbox 2008-12-15 aclarke ?>
<noscript>
<?php
  echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>';
?>
</noscript>
</div>

majiczoom =

<?php
/**
 * (C) CopyRight 2008 MagicToolBox - www.magictoolbox.com - [email protected]
 */
 //         includes/modules/
 
 $defaultView = false;
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<?php if (ZEN_MAGICZOOM_STATUS == 'true') { ?>
    <?php
        $products_name = $current_page_base == 'product_reviews' ? $products_name_reviews_page : $products_name;
        $tplDIR = $db->Execute("select template_dir from " . TABLE_TEMPLATE_SELECT);
        $tplDIR = $tplDIR->fields['template_dir'];
        
        require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
        /* load module */
        $mod = & magictoolboxLoadModule('MagicZoom');
        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . str_replace(DIR_WS_IMAGES, '', $products_image_large))) {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image_large);
        } else {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image);
        }



        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $image) && !$mod->params->checkValue("use-effect-on-product-page", "No")) {
            $img = DIR_WS_CATALOG . DIR_WS_IMAGES . $image;
            $thumb = DIR_WS_CATALOG . magictoolboxGetThumb($image, $mod->params->getValue('thumb-size'), $mod->params->getValue('thumb-size-depends-on'), $mod->params->getValue('image-magick-path'));
            
            $id = 'MainImage';
            $title = $products_name;
            $description = $products_description;        
            
            /* zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) */
            /* javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\') */
    
            if(!defined('MAGICZOOM_ADDONS_TEMPLATE_LOADED')) {
                echo $mod->addonsTemplate(DIR_WS_CATALOG . DIR_WS_TEMPLATE . 'images');
                define('MAGICZOOM_ADDONS_TEMPLATE_LOADED', true);
            }
    
            echo $mod->template(compact("img","thumb","id","title","description"));
            //$mod->();
        } else {
            $defaultView = true;
        }
    ?>
<?php } else { $defaultView = true; } ?>
<?php if($defaultView) { ?>
    <script language="javascript" type="text/javascript"><!--
        document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
    //--></script>
    <noscript><?php echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?></noscript>
<?php } ?>
</div>

thanks

13 Mar 2011, 12:09 PM
#4
noreko avatar

noreko

New Zenner

Join Date:
Mar 2011
Posts:
1
Plugin Contributions:
0

Re: IH and zen lightbox and zoom addons clash on edits to same file

Hi Try this Code for tpl_modules_main_product_image.php not the best way but it is working

<?php
/**
 * (C) CopyRight 2008 MagicToolBox - www.magictoolbox.com - [email protected]
 */
 //         includes/modules/
 
 $defaultView = false;
?>
<?php require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_MAIN_PRODUCT_IMAGE)); ?> 
<div id="productMainImage" class="centeredContent back">
<?php if (ZEN_MAGICZOOM_STATUS == 'true') { ?>
    <?php
        $products_name = $current_page_base == 'product_reviews' ? $products_name_reviews_page : $products_name;
        $tplDIR = $db->Execute("select template_dir from " . TABLE_TEMPLATE_SELECT);
        $tplDIR = $tplDIR->fields['template_dir'];
        
        require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
        /* load module */
        $mod = & magictoolboxLoadModule('MagicZoom');
        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . str_replace(DIR_WS_IMAGES, '', $products_image_large))) {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image_large);
        } else {
            $image = str_replace(DIR_WS_IMAGES, '', $products_image);
        }





        if(file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $image) && $mod->params->checkValue("use-effect-on-product-page", "Yes")) {
            if ($mod->type == 'standard') {
                if(isset($_GET['products_id'])) $pid = $_GET['products_id']; else $pid = null;
                $img = DIR_WS_CATALOG . magictoolboxGetThumb($image, 'original', $mod->params, $pid);
                $thumb = DIR_WS_CATALOG . magictoolboxGetThumb($image, 'thumb', $mod->params, $pid);

                $id = 'MainImage';
                $title = $products_name;
                $description = $products_description;

                /* zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) */
                /* javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\') */

                if(!defined('MAGICZOOM_ADDONS_TEMPLATE_LOADED')) {
                    echo $mod->addonsTemplate(DIR_WS_CATALOG . DIR_WS_TEMPLATE . 'images');
                    define('MAGICZOOM_ADDONS_TEMPLATE_LOADED', true);
                }
				if (ZEN_LIGHTBOX_STATUS == 'true') {
  if (ZEN_LIGHTBOX_GALLERY_MODE == 'true' && ZEN_LIGHTBOX_GALLERY_MAIN_IMAGE == 'true') {
    $rel = 'lightbox-g';
  } else {
    $rel = 'lightbox';
  }

$img = zen_lightbox($products_image_large). '" rel="' . $rel ;
?>
<script language="javascript" type="text/javascript"><!--
document.write('<?php echo $mod->template(compact("img","thumb","id","title","description")); ?>');
//--></script>
<?php }
            } elseif($mod->type == 'category') {
                require(DIR_FS_CATALOG . DIR_WS_MODULES . $tplDIR . '/additional_images.php');
                if(count($images) > 1) {
                    foreach($images as $k => $img) {
                        $images[$k]['img'] = $images[$k]['medium'];
                    }

                    echo $mod->template($images);
                } else {
                    $defaultView = true;
                }
            } elseif($mod->type == 'circle') {
                require(DIR_FS_CATALOG . DIR_WS_MODULES . $tplDIR . '/additional_images.php');
                if(count($images) > 0 && $mod->enabled($images, $products_id)) {
                    echo $mod->template($images);
                } else {
                    $defaultView = true;
                }
            } else {
                $defaultView = true;
            }
        } else {
            $defaultView = true;
        }
    ?>
<?php } else { $defaultView = true; } ?>
<?php if($defaultView) { $GLOBALS['MAGICTOOLBOX_additional_images_defaultView'] = true; ?>
    <script language="javascript" type="text/javascript"><!--
        document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '\\\')">' . zen_image($products_image_medium, addslashes($products_name), MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?>');
    //--></script>
    <noscript><?php echo '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $_GET['products_id']) . '" target="_blank">' . zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT) . '<br /><span class="imgLink">' . TEXT_CLICK_TO_ENLARGE . '</span></a>'; ?></noscript>
<?php } ?>
</div>

for additional_images.php

<?php
/**
 * (C) CopyRight 2008 MagicToolBox - www.magictoolbox.com - [email protected]
 */
 
 /*
     image/
        .....
            subdir/
                    ......
                        imageName.extension - base
                        imageName**.extension - additional
                        large/imageName**_LRG.extension - large images
                        medium/imageName**_MED.extension - medium images 
                        
      MagicToolbox use only large images. All thumbnails will be dinamicaly created 
 */
if (!defined('IS_ADMIN_FLAG')) die('Illegal Access');

if(!isset($GLOBALS['MAGICTOOLBOX_additional_images_defaultView'])) {
    $GLOBALS['MAGICTOOLBOX_additional_images_defaultView'] = false;
}
if (!defined('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE')) define('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE','Yes');
$images_array = array();

if ($products_image != '' && $flag_show_product_info_additional_images != 0) {
  // prepare image name
  $products_image_extension = substr($products_image, strrpos($products_image, '.'));
  $products_image_base = str_replace($products_image_extension, '', $products_image);

  // if in a subdirectory
  if (strrpos($products_image, '/')) {
    $products_image_match = substr($products_image, strrpos($products_image, '/')+1);
    //echo 'TEST 1: I match ' . $products_image_match . ' - ' . $file . ' -  base ' . $products_image_base . '<br>';
    $products_image_match = str_replace($products_image_extension, '', $products_image_match) . '_';
    $products_image_base = $products_image_match;
  }

  $products_image_directory = str_replace($products_image, '', substr($products_image, strrpos($products_image, '/')));
  if ($products_image_directory != '') {
    $products_image_directory = DIR_WS_IMAGES . str_replace($products_image_directory, '', $products_image) . "/";
  } else {
    $products_image_directory = DIR_WS_IMAGES;
  }

  // Check for additional matching images
  $file_extension = $products_image_extension;
  $products_image_match_array = array();
  if ($dir = @dir($products_image_directory)) {
    while ($file = $dir->read()) {
      if (!is_dir($products_image_directory . $file)) {
        if (substr($file, strrpos($file, '.')) == $file_extension) {
          //          if(preg_match("/" . $products_image_match . "/i", $file) == '1') {
          if(preg_match("/" . $products_image_base . "/i", $file) == 1) {
            if ($file != $products_image) {
              if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
                //  echo 'I AM A MATCH ' . $file . '<br>';
                $images_array[] = $file;
              } else {
                //  echo 'I AM NOT A MATCH ' . $file . '<br>';
              }
            }
          }
        }
      }
    }
    if (sizeof($images_array)) {
      sort($images_array);
    }
    $dir->close();
  }
}
// Build output based on images found
$num_images2 = sizeof($images_array);
$list_box_contents2 = '';
$title2 = '';

if ($num_images2) {
  $row2 = 0;
  $col2 = 0;
  if ($num_images2 < IMAGES_AUTO_ADDED || IMAGES_AUTO_ADDED == 0 ) {
    $col_width2 = floor(100/$num_images2);
  } else {
    $col_width2 = floor(100/IMAGES_AUTO_ADDED);
  }
  for ($i2=0, $n=$num_images2; $i2<$n; $i2++) {
    $file = $images_array[$i2];
    $products_image_large = str_replace(DIR_WS_IMAGES, DIR_WS_IMAGES . 'large/', $products_image_directory) . str_replace($products_image_extension, '', $file) . IMAGE_SUFFIX_LARGE . $products_image_extension;
	// bof Zen Lightbox 2008-12-11 aclarke
	if (function_exists('handle_image')) {
	  $flag_has_large = true;
	} else {
	// eof Zen Lightbox 2008-12-11 aclarke
	$flag_has_large = file_exists($products_image_large);
	// bof Zen Lightbox 2008-12-11 aclarke
	}
	// eof Zen Lightbox 2008-12-11 aclarke
    $products_image_large = ($flag_has_large ? $products_image_large : $products_image_directory . $file);
    $flag_display_large = (IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE == 'Yes' || $flag_has_large);
    $base_image = $products_image_directory . $file;
    $thumb_slashes = zen_image($base_image, addslashes($products_name), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
	// bof Zen Lightbox 2008-12-11 aclarke
	if (function_exists('handle_image')) {
	// remove additional single quotes from image attributes (important!)
    $thumb_slashes = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
	}
	// eof Zen Lightbox 2008-12-11 aclarke
    $thumb_regular = zen_image($base_image, $products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    $large_link = zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large);

$script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="' . zen_lightbox($products_image_large, addslashes($products_name), LARGE_IMAGE_WIDTH, LARGE_IMAGE_HEIGHT) . '" rel="' . $rel . '" title="' . addslashes($products_name) . '">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';
echo ('<div style="display:none" >' .$script_link .'</div>');
}  }

// if Magic Zoom enabled
if (ZEN_MAGICZOOM_STATUS == 'true' && !$GLOBALS['MAGICTOOLBOX_additional_images_defaultView']) {
    
    //load module
    require_once(DIR_FS_CATALOG . DIR_WS_MODULES . 'magictoolbox/magictoolbox_addons.php');
    $mod = & magictoolboxLoadModule('MagicZoom');

    $images = array();

    if(!isset($GLOBALS['magictoolbox']['images'])) {
        // we can load additional images only if base image present
        if (!empty($products_image)) {
            $info = pathinfo($products_image);
            if(intval(phpversion()) < 5 || !isset($info["filename"])) {
                $info["filename"] = basename($info["basename"], ".".$info["extension"]);
            }
            if($info["dirname"] == '.') $info["dirname"] = '';
            if(!empty($info["dirname"])) $info["dirname"] .= '/';    
            $images = glob(DIR_FS_CATALOG . DIR_WS_IMAGES . $info["dirname"] . $info["filename"] . '*.' . $info["extension"]);
            // found only original image
            //if (count($images) == 1) $images = array();
            // sort images
            if (count($images) > 0) {
                sort($images);
                $_images = array();
                foreach($images as $img) {
                    if($img == DIR_FS_CATALOG . DIR_WS_IMAGES . $info["dirname"] . $info["filename"] . '.' . $info["extension"]) {
                        $main = true;
                    } else {
                        $main = false;
                    }
                    $img = str_replace(DIR_FS_CATALOG . DIR_WS_IMAGES, '', $img);

                    $info = pathinfo($img);
                    if(intval(phpversion()) < 5 || !isset($info["filename"])) {
                        $info["filename"] = basename($info["basename"], ".".$info["extension"]);
                    }
                    if($info["dirname"] == '.') $info["dirname"] = '';
                    if(!empty($info["dirname"])) $info["dirname"] .= '/';
                    $lrg = 'large/' . $info['dirname'] . $info['filename'] . IMAGE_SUFFIX_LARGE .'.'. $info['extension'];
                    if(!file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . $lrg)) $lrg = $img;
                    if(isset($_GET['products_id'])) $pid = $_GET['products_id']; else $pid = null;
                    $_images[] = array(
                        'main' => $main,
                        'img' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'original', $mod->params, $pid),
                        'medium' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'thumb', $mod->params, $pid),
                        'thumb' => DIR_WS_CATALOG . magictoolboxGetThumb($lrg, 'selector', $mod->params, $pid)
                    );
                }
                $GLOBALS['magictoolbox']['images'] = $images = $_images;
            }
        }
    } else {
        $images = $GLOBALS['magictoolbox']['images'];
    }

  if($mod->type == 'standard') {
    $list_box_contents = array();
    $title = '';
    $c = count($images);
    
    if ($c > 1) {
        $row = $col = 0;
        if ($c < IMAGES_AUTO_ADDED || IMAGES_AUTO_ADDED == 0 ) {
            $col_width = floor(100/$c);
        } else {
            $col_width = floor(100/IMAGES_AUTO_ADDED);
        }
    
        foreach($images as $image) {

            $img = $image['img'];
            $medium = $image['medium'];
            $thumb = $image['thumb'];
            $id = 'MainImage';

                $link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . $mod->subTemplate(compact("img","thumb","medium","id")) . '\');' . "\n" . '//--></script>';
            //$link = $mod->subTemplate(compact("img","thumb","medium","id"));
        
            // List Box array generation:
            $list_box_contents[$row][$col] = array('params' => 'class="additionalImages centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
            'text' => "\n      " . $link);
            $col ++;
            if ($col > (IMAGES_AUTO_ADDED -1)) {
            $col = 0;
            $row ++;
            }
        }
    }
    $num_images = $c;
  }
} else {
    //if disabled Magic Zoom then default template will be loaded
    require_once(dirname(dirname(__FILE__)) . "/" . basename(__FILE__));
}

?>

best wishes from Germany

19 Mar 2011, 1:29 AM
#5
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: IH and zen lightbox and zoom addons clash on edits to same file

abs007:

Hi All
I added the zen lightbox to my site and its working fine along with image handler 2. I would also like to add a zoom addon however they are both using a

includes>templates>MYTEMPLATE>templates>tpl_modules_main_product_image.php

anyone know how I can get these 2 to work alongside each other?

thanks

IH already has the ability to give that zoom into the page when you hover over the small image---you see the medium one

or is that not what you meant.