function mopics_getmethod($pattern) { return str_replace(array('{', '}'), '', mopics_match_pattern($pattern)); }
Copyright 2000 - 2011 osCmax Released under the GNU General Public License */ // Backwards support for older osCommerce versions if (isset($product_info_values) && is_object($product_info_values)) { $product_info =& $product_info_values; } // Set the thumbnail basename; replaces "imagebase" in the user's pattern $image_base = mopics_get_imagebase($products_image_name, $root_thumbs); // Set the large image's basename; replaces "imagebase" in the user's pattern $image_base_lg = mopics_get_imagebase($products_image_name, $root_images_dir); // Get the counting method for the user's pattern (1,2,3; a,b,c; A,B,C; etc) $i = mopics_getmethod(DYNAMIC_MOPICS_PATTERN); // Set the search for the str_replace pattern search/replace $search = array('imagebase', mopics_match_pattern(DYNAMIC_MOPICS_PATTERN)); // Set the initial replace for the str_replace pattern search/replace $replace = array($image_base, $i); // Are there any extra thumbnails for this product? if (mopics_file_exists(str_replace($search, $replace, DYNAMIC_MOPICS_PATTERN))) { ?> <tr> <td> <div class="screenshotsHeader"> <div class="screenshotsHeaderText">Other images for this product:</div> </div> <div class="screenshotsBlock"> <div align="center"> <div class="screenshots"> <?php $row = 0;
function MagicToolboxParse($content = null) { $stsMod = false; if ($content == null) { $content = ob_get_contents(); ob_clean(); } else { $stsMod = true; ob_end_flush(); } $mtClass =& $GLOBALS["MagicToolboxModuleClass"]; //$conf = $mtClass->getConf(); $product_info = $GLOBALS["product_info"]; // is Enabled Color Swatches on current page $_csw = false; if ($GLOBALS['products_image'] != $product_info['products_image']) { $_csw = true; } //die("<div style=\"display:none;\">".print_r($GLOBALS,true)."</div>"); $categoryPage = false; $productPage = false; /* if((!$mtClass->curClass->params->checkValue("use-effect-on-category-page", "No") && ($GLOBALS['category_depth'] == 'products' && intval($GLOBALS['current_category_id']) > 0 || intval($_GET['manufacturers_id']) > 0) || $GLOBALS['category_depth'] == 'top' && !$mtClass->curClass->params->checkValue('use-effect-on-hp-whats-new-block', 'No')) && (preg_match("/index\.php/is", $GLOBALS['_SERVER']['REQUEST_URI']) || preg_match('/-[cm]-[0-9_]+\.html/is', $GLOBALS['_SERVER']['REQUEST_URI'])) || !$mtClass->curClass->params->checkValue('use-effect-on-new-products-page', 'No') && $GLOBALS['_SERVER']['SCRIPT_NAME'] == '/products_new.php') */ if (1 == 1) { $list_box_contents = $GLOBALS['list_box_contents']; $info_box_contents = $GLOBALS['info_box_contents']; //print_r($list_box_contents); die(); if (preg_match('/productListing-heading/is', $list_box_contents[0][0]['params'])) { // remove table header array_shift($list_box_contents); } if (!isset($list_box_contents[0]['text']) && @(!isset($list_box_contents[0][1]['text']))) { $products_list_contents = $info_box_contents; } else { $products_list_contents = $list_box_contents; } if ($mtClass->curClass->params->checkValue('use-effect-on-category-page', 'Zoom')) { $mtClass->curClass->params->set('disable-expand', 'Yes'); $mtClass->curClass->params->set('disable-zoom', 'No'); $mtClass->curClass->params->set('use-effect-on-category-page', 'Yes'); } elseif ($mtClass->curClass->params->checkValue('use-effect-on-category-page', 'Expand')) { $mtClass->curClass->params->set('disable-zoom', 'Yes'); $mtClass->curClass->params->set('disable-expand', 'No'); $mtClass->curClass->params->set('use-effect-on-category-page', 'Yes'); } if ($mtClass->curClass->params->checkValue('use-effect-on-hp-whats-new-block', 'Zoom')) { $mtClass->curClass->params->set('disable-expand', 'Yes'); $mtClass->curClass->params->set('disable-zoom', 'No'); $mtClass->curClass->params->set('use-effect-on-hp-whats-new-block', 'Yes'); } elseif ($mtClass->curClass->params->checkValue('use-effect-on-hp-whats-new-block', 'Expand')) { $mtClass->curClass->params->set('disable-zoom', 'Yes'); $mtClass->curClass->params->set('disable-expand', 'No'); $mtClass->curClass->params->set('use-effect-on-hp-whats-new-block', 'Yes'); } if ($mtClass->curClass->params->checkValue('use-effect-on-new-products-page', 'Zoom')) { $mtClass->curClass->params->set('disable-expand', 'Yes'); $mtClass->curClass->params->set('disable-zoom', 'No'); $mtClass->curClass->params->set('use-effect-on-new-products-page', 'Yes'); } elseif ($mtClass->curClass->params->checkValue('use-effect-on-new-products-page', 'Expand')) { $mtClass->curClass->params->set('disable-zoom', 'Yes'); $mtClass->curClass->params->set('disable-expand', 'No'); $mtClass->curClass->params->set('use-effect-on-new-products-page', 'Yes'); } $categoryPage = true; } if ($mtClass->curClass->params->checkValue("enabled", true) && !$mtClass->curClass->params->checkValue("use-effect-on-product-page", "No") && $product_info && is_array($product_info)) { $productPage = true; if ($mtClass->curClass->params->checkValue('use-effect-on-product-page', 'Zoom')) { $mtClass->curClass->params->set('disable-expand', 'Yes'); $mtClass->curClass->params->set('disable-zoom', 'No'); } elseif ($mtClass->curClass->params->checkValue('use-effect-on-product-page', 'Expand')) { $mtClass->curClass->params->set('disable-zoom', 'Yes'); $mtClass->curClass->params->set('disable-expand', 'No'); } /* backup left/right columns content */ $contentBackup = preg_replace('/^(.*?<\\!--\\sbody_text\\s\\/\\/-->)(.*?)(<\\!--\\sbody_text_eof\\s\\/\\/-->.*)$/is', '$1_MAGICTOOLBOX_COLUMNS_BACKUP_$3', $content); if ($contentBackup === null || $contentBackup == $content) { $contentBackup = false; } else { $content = preg_replace('/^(.*?<\\!--\\sbody_text\\s\\/\\/-->)(.*?)(<\\!--\\sbody_text_eof\\s\\/\\/-->.*)$/is', '$2', $content); } /* backup left/right columns content in OscMax */ if ($contentBackup == false) { $contentBackup = preg_replace('/^(.*?<\\!--\\scontent\\s\\/\\/-->)(.*?)(<\\!--\\scontent_eof\\s\\/\\/-->.*)$/is', '$1_MAGICTOOLBOX_COLUMNS_BACKUP_$3', $content); if ($contentBackup === null || $contentBackup == $content) { $contentBackup = false; } else { $content = preg_replace('/^(.*?<\\!--\\scontent\\s\\/\\/-->)(.*?)(<\\!--\\scontent_eof\\s\\/\\/-->.*)$/is', '$2', $content); } } /* backup <noscript> tags */ $GLOBALS["magictoolbox_noscripts_backups"] = array(); $content = preg_replace_callback("/(<noscript>.*<\\/noscript>)/iUs", "MagicToolbox_callback_noscript", $content); if (!$GLOBALS["mz_osc_cre"]) { /* product image parce - only for original osCommerce distributive (no CRELoaded engine!)*/ $product_image = $product_info["products_image"]; $srcAddons = ''; if ($_csw && OPTIONS_AS_COLOR_SWATCHES_ENABLED && is_array($GLOBALS['products_options_array']) && !empty($GLOBALS['products_options_array'])) { $srcAddons = array(); foreach ($GLOBALS['products_options_array'] as $po) { // comented.. maybe should be used for old versions of color swatches //$srcAddons[] = $po['att_id']; $srcAddons[] = preg_quote($po['image'], '/'); } //$srcAddons = '(?:(?:options\/)?(?:(?:' . implode(')|(?:', $srcAddons) . '))_)?'; $srcAddons = '(?:(?:options\\/)?(?:(?:' . implode(')|(?:', $srcAddons) . ')))?'; $product_image = ""; } if (isset($product_info["products_largeimage"]) && !empty($product_info["products_largeimage"])) { /* support Sm,Med,and Lg Images osCommerce addon (http://addons.oscommerce.com/info/695) */ $product_image = $product_info["products_largeimage"]; } if (isset($product_info["products_image_med"]) && isset($product_info["products_image_pop"])) { if (!empty($product_info["products_image_med"])) { $product_image = $product_info["products_image_med"]; } elseif (!empty($product_info["products_image_pop"])) { $product_image = $product_info["products_image_pop"]; } } if (isset($product_info["products_image_med"]) && !empty($product_info["products_largeimage"])) { /* support Additional Images Module osCommerce addon (http://addons.oscommerce.com/info/1032) */ $product_image = $product_info["products_largeimage"]; } if (function_exists('thumbimage')) { // support Automatic Thumbnail oscommerce addon $GLOBALS['magictoolbox']['product_image_orig'] = $GLOBALS["magictoolbox_dir_ws_images"] . $product_image; $product_image = $GLOBALS["magictoolbox_dir_ws_images_quoted"] . '(thumbs_cache\\/)?(imagecache\\/([0-9]+x[0-9]+_)?)?' . preg_quote($product_image, "/"); } else { $product_image = $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $srcAddons . preg_quote($product_image, "/"); } $pattern = "<img[^>]*src=\"((?:(?:(?:product_thumb)|(?:imagemagic)|(?:oscthumb))\\.php\\?(?:img|src)\\=)?\\/?" . $product_image . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; //die($pattern); $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_product", $content); } /* color swatches */ if ($_csw && OPTIONS_AS_COLOR_SWATCHES_ENABLED && is_array($GLOBALS['products_options_array']) && !empty($GLOBALS['products_options_array'])) { $mainImageId = preg_replace('/^.*?<a[^>]*?class=\\"' . $GLOBALS["MagicToolboxModuleCurrent"] . '\\"[^>]*?id=\\"([^\\"\\>]*)\\".*$/is', "\$1", $content); if ($mainImageId == $content) { $mainImageId = preg_replace('/^.*?<a[^>]*?id=\\"([^\\"\\>]*)\\"[^>]*?class=\\"' . $GLOBALS["MagicToolboxModuleCurrent"] . '\\".*$/is', "\$1", $content); } if ($mainImageId != $content) { $pattern = "<div id='div_colors' name='div_colors'([^>]*?)onMouseOver=change_product_image\\((.*?)\\) onMouseOut=change_product_image_back\\((this)\\)><\\/div>"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_colorSwatches", $content); $scripts = "function MagicToolbox_change_product_image_back(obj){}"; $scripts .= "function MagicToolbox_change_product_image(obj,img,att_id,id,thumb){"; if ('magiczoomplus' == 'magiczoom2') { $scripts .= "MagicZoom_stopZooms();"; } if ('magiczoomplus' == 'magiczoom') { $scripts .= "MagicZoom.stop({$j}('{$mainImageId}'));"; } if ('magiczoomplus' == 'magicmagnify') { $scripts .= "MagicMagnify_stopMagnifiers();"; } $scripts .= "var path = '" . DIR_WS_IMAGES . "' + ((att_id==0) ? '' : 'options/');\r\n window.document.getElementsByName('id[1]')[0].value=id;\r\n colors = window.document.getElementsByName('div_colors');\r\n for(i=0;i<colors.length;i++){\r\n if(colors[i]!=obj){\r\n colors[i].style.border='2px solid #BBBBBB';\r\n }\r\n }\r\n window.document.getElementById('{$mainImageId}').href= path+img ;"; $scripts .= "window.document.getElementById('{$mainImageId}').firstChild.src= thumb;\r\n obj.style.border='2px solid #000000';"; if ('magiczoomplus' == 'magiczoom2') { $scripts .= "MagicZoom_findZooms();"; } if ('magiczoomplus' == 'magiczoom') { $scripts .= "MagicZoom.start({$j}('{$mainImageId}'));"; } if ('magiczoomplus' == 'magicmagnify') { $scripts .= "MagicMagnify_findMagnifiers();"; } if ('magiczoomplus' == 'magicthumb') { $scripts .= "MagicThumb.refresh();"; } $scripts .= "}"; $content = preg_replace("/(function change_product_image\\()/is", $scripts . "\$1", $content); } } /* support Additional Images Module osCommerce addon (http://addons.oscommerce.com/info/1032) */ if (tep_db_num_rows(tep_db_query("show tables like 'additional_images'")) >= 1) { $products_additional_images_query = tep_db_query("SELECT thumb_images, medium_images FROM " . TABLE_ADDITIONAL_IMAGES . " WHERE products_id='" . intval($product_info['products_id']) . "'"); if (tep_db_num_rows($products_additional_images_query) >= 1) { while ($additional_image = tep_db_fetch_array($products_additional_images_query)) { if (!empty($additional_image['medium_images'])) { $img = $additional_image['medium_images']; } else { $img = $additional_image['thumb_images']; } $GLOBALS["mz_current_ultra_pic"] = preg_replace('/[sml]\\.([^\\.]+)$/is', '.$1', $img); $img = preg_quote($img, "/"); $pattern = "<img[^>]*src=\"(" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $img . ")\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); unset($GLOBALS["mz_current_ultra_pic"]); } } } /* extra images */ if (tep_db_num_rows(tep_db_query("show tables like 'products_extra_images'")) >= 1) { $products_extra_images_query = tep_db_query("SELECT products_extra_image FROM " . TABLE_PRODUCTS_EXTRA_IMAGES . " WHERE products_id='" . intval($product_info['products_id']) . "'"); if (tep_db_num_rows($products_extra_images_query) >= 1) { while ($extra_image = tep_db_fetch_array($products_extra_images_query)) { $GLOBALS["mz_current_ultra_pic"] = $extra_image['products_extra_image']; $extra_image = preg_quote($extra_image['products_extra_image'], "/"); $pattern = "<img[^>]*src=\"((?:product_thumb\\.php\\?img\\=)?" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $extra_image . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); unset($GLOBALS["mz_current_ultra_pic"]); } $pattern = "<img[^>]*src=\"(" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . preg_quote($product_info['products_image'], '/') . ")\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); } } //BOF:mod 20120207 /* product versions */ if ($product_info['parent_products_id'] != $product_info['products_id']) { $product_versions_query = tep_db_query("select a.products_id, a.products_image, b.products_name from products a inner join products_description b on (a.products_id=b.products_id and b.language_id='1') where ((parent_products_id='" . (int) $product_info['parent_products_id'] . "' and a.products_id<>'" . (int) $product_info['products_id'] . "') or (a.products_id='" . (int) $product_info['parent_products_id'] . "')) order by b.products_name"); } else { $product_versions_query = tep_db_query("select a.products_id, a.products_image, b.products_name from products a inner join products_description b on (a.products_id=b.products_id and b.language_id='1') where parent_products_id='" . (int) $product_info['products_id'] . "' order by b.products_name"); } if (tep_db_num_rows($product_versions_query)) { while ($version = tep_db_fetch_array($product_versions_query)) { $GLOBALS["mz_current_ultra_pic"] = $version['products_image']; $version_image = preg_quote($version['products_image'], "/"); $pattern = "<img[^>]*src=\"((?:product_thumb\\.php\\?img\\=)?" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $version_image . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); unset($GLOBALS["mz_current_ultra_pic"]); } /*$pattern = "<img[^>]*src=\"(" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . preg_quote($product_info['products_image'], '/') . ")\"[^>]*(?:>)(?:[^<]*<\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content);*/ } //EOF:mod 20120207 /* More Pics 6 (extra pics) v 1.3 */ foreach ($product_info as $fieldName => $fieldValue) { if (preg_match("/^products_subimage[1-6]\$/is", $fieldName)) { $extra_image = preg_quote($fieldValue, "/"); $pattern = "<img[^>]*src=\"((?:product_thumb\\.php\\?img\\=)?" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $extra_image . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); } } /* ultra pics */ $ultraPics = array(); foreach ($product_info as $fieldName => $fieldValue) { preg_match("/^products_image_((?:sm)|(?:xl))_([0-9]+)\$/is", $fieldName, $matches); if (!empty($matches)) { if (!isset($ultraPics[intval($matches[2])])) { $ultraPics[intval($matches[2])] = array(); } $ultraPics[intval($matches[2])][$matches[1] == "sm" ? "thumb" : "img"] = $fieldValue; } } foreach ($ultraPics as $pic) { if (!isset($pic["img"]) || empty($pic["img"])) { continue; } if (!isset($pic["thumb"]) || empty($pic["thumb"])) { $thumbExists = false; $pic["thumb"] = $pic["img"]; } else { $thumbExists = true; } $img = preg_quote($pic["thumb"], "/"); $pattern = "<img[^>]*src=\"((?:product_thumb\\.php\\?img\\=)?" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . $img . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; if ($thumbExists) { $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; } $GLOBALS["mz_current_ultra_pic"] = $pic["img"]; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); unset($GLOBALS["mz_current_ultra_pic"]); } /* support: Dynamic MoPics (http://www.oscommerce.com/community/contributions,1114) */ ob_start(); include DIR_WS_MODULES . 'dynamic_mopics.php'; $moPicsContents = ob_get_contents(); ob_end_clean(); $moPicsContents = preg_replace('/<noscript>.*?<\\/noscript>/is', '', $moPicsContents); $pattern = $GLOBALS["magictoolbox_dir_ws_images_quoted"] . '[^\\"\\>]+?'; $pattern = '<img[^>]*src=\\"(' . $pattern . ')\\"[^>]*(?:\\/?>)'; $pattern = '(?:<a[^>]*?href=\\"[^\\"]+?\\\\\'(.*?)\\\\\'[^\\"]+?\\"[^>]*>)' . $pattern . '(.*?)(?:<\\/a>)'; preg_match_all('/' . $pattern . '/is', $moPicsContents, $moPicsMatches); foreach ($moPicsMatches[2] as $key => $thumb) { $href = $moPicsMatches[1][$key]; $pic = preg_replace('/^.*?(?:\\?|\\&)pic\\=(.*?)(?:\\&.*|)$/is', '$1', $href); $type = preg_replace('/^.*?(?:\\?|\\&)type\\=(.*?)(?:\\&.*|)$/is', '$1', $href); $imagebase = mopics_get_imagebase($product_info['products_image'], DIR_WS_IMAGES . DYNAMIC_MOPICS_BIGIMAGES_DIR); $search = array('imagebase', mopics_match_pattern(DYNAMIC_MOPICS_PATTERN)); $replace = array($imagebase, $pic); $image = str_replace($search, $replace, DYNAMIC_MOPICS_PATTERN) . '.' . $type; $image = str_replace($GLOBALS['magictoolbox_dir_ws_images'], '', $image); $GLOBALS["mz_current_ultra_pic"] = $image; $pattern = "<img[^>]*src=\"((?:product_thumb\\.php\\?img\\=)?" . preg_quote($thumb, '/') . "(?:\\&[^\\&\"]+)*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>){$pattern}(.*?)(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_extra", $content); unset($GLOBALS["mz_current_ultra_pic"]); } /* paps images */ if (isset($GLOBALS["arr_filenames"])) { $paps_images = $GLOBALS["arr_filenames"]; } else { $paps_images = array(); } if (count($paps_images) > 0) { foreach ($paps_images as $paps_image) { $paps_image = preg_quote($paps_image, "/"); $pattern = "<img[^>]*src=\"(paps_makethumb.php\\?pic\\=(" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . "paps\\/{$paps_image})[^\"]*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(?:<a[^>]*>\\s*){$pattern}(?:<\\/a>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_paps", $content); } } /* main paps image */ $pattern = "<img[^>]*src=\"(paps_makethumb.php\\?pic\\=" . $GLOBALS["magictoolbox_dir_ws_images_quoted"] . "paps\\/[^\"]*)\"[^>]*(?:>)(?:[^<]*<\\/img>)?"; $pattern = "(<td[^>]*>\\s*){$pattern}(\\s*<\\/td>)"; $content = preg_replace_callback("/{$pattern}/is", "callback_MagicToolbox_paps_main", $content); /* restore <noscript> tags */ foreach ($GLOBALS["magictoolbox_noscripts_backups"] as $k => $noscript) { $content = str_replace("_MAGICTOOLBOX_NOSCRIPT_BACKUP_" . ($k + 1), $noscript, $content); } unset($GLOBALS["magictoolbox_noscripts_backups"]); /* restore left/right columns content */ if ($contentBackup) { $content = str_replace('_MAGICTOOLBOX_COLUMNS_BACKUP_', $content, $contentBackup); } } if (($categoryPage || $productPage) && !defined('_MAGICTOOLBOX_MODULE')) { define('_MAGICTOOLBOX_MODULE', 1); /* load JS and CSS */ if ($stsMod == true || $categoryPage == true) { $pattern = '/^.*$/is'; } else { $pattern = '/<\\/head>/is'; } $content = preg_replace_callback($pattern, "callback_MagicToolbox_head", $content); } if ($stsMod == true) { return $content; } else { echo $content; } }