[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 additional_images.php

Zen Cart 源代码 additional_images.php




下载文件

文件名: additional_images.php
文件类型: PHP文件
文件大小: 5.58 KiB
MD5: 78c1d88141808d6e9fc2dce709c9aeff

additional_images.php - 关闭高亮
  1. <?php
  2. /**
  3.  * additional_images module
  4.  *
  5.  * Prepares list of additional product images to be displayed in template
  6.  *
  7.  * @package templateSystem
  8.  * @copyright Copyright 2003-2010 Zen Cart Development Team
  9.  * @copyright Portions Copyright 2003 osCommerce
  10.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  11.  * @version $Id: additional_images.php 16913 2010-07-16 03:38:06Z ajeh $
  12.  */
  13. if (!defined('IS_ADMIN_FLAG')) {
  14.   die('Illegal Access');
  15. }
  16. if (!defined('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE')) define('IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE','Yes');
  17. $images_array = array();
  18.  
  19. // do not check for additional images when turned off
  20. if ($products_image != '' && $flag_show_product_info_additional_images != 0) {
  21.   // prepare image name
  22.   $products_image_extension = substr($products_image, strrpos($products_image, '.'));
  23.   $products_image_base = str_replace($products_image_extension, '', $products_image);
  24.  
  25.   // if in a subdirectory
  26.   if (strrpos($products_image, '/')) {
  27.     $products_image_match = substr($products_image, strrpos($products_image, '/')+1);
  28.     //echo 'TEST 1: I match ' . $products_image_match . ' - ' . $file . ' -  base ' . $products_image_base . '<br>';
  29.     $products_image_match = str_replace($products_image_extension, '', $products_image_match) . '_';
  30.     $products_image_base = $products_image_match;
  31.   }
  32.  
  33.   $products_image_directory = str_replace($products_image, '', substr($products_image, strrpos($products_image, '/')));
  34.   if ($products_image_directory != '') {
  35.     $products_image_directory = DIR_WS_IMAGES . str_replace($products_image_directory, '', $products_image) . "/";
  36.   } else {
  37.     $products_image_directory = DIR_WS_IMAGES;
  38.   }
  39.  
  40.   // Check for additional matching images
  41.   $file_extension = $products_image_extension;
  42.   $products_image_match_array = array();
  43.   if ($dir = @dir($products_image_directory)) {
  44.     while ($file = $dir->read()) {
  45.       if (!is_dir($products_image_directory . $file)) {
  46.         if (substr($file, strrpos($file, '.')) == $file_extension) {
  47.           //          if(preg_match("/" . $products_image_match . "/i", $file) == '1') {
  48.           if(preg_match("/" . $products_image_base . "/i", $file) == 1) {
  49.             if ($file != $products_image) {
  50.               if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
  51.                 //  echo 'I AM A MATCH ' . $file . '<br>';
  52.                 $images_array[] = $file;
  53.               } else {
  54.                 //  echo 'I AM NOT A MATCH ' . $file . '<br>';
  55.               }
  56.             }
  57.           }
  58.         }
  59.       }
  60.     }
  61.     if (sizeof($images_array)) {
  62.       sort($images_array);
  63.     }
  64.     $dir->close();
  65.   }
  66. }
  67.  
  68. // Build output based on images found
  69. $num_images = sizeof($images_array);
  70. $list_box_contents = '';
  71. $title = '';
  72.  
  73. if ($num_images) {
  74.   $row = 0;
  75.   $col = 0;
  76.   if ($num_images < IMAGES_AUTO_ADDED || IMAGES_AUTO_ADDED == 0 ) {
  77.     $col_width = floor(100/$num_images);
  78.   } else {
  79.     $col_width = floor(100/IMAGES_AUTO_ADDED);
  80.   }
  81.  
  82.   for ($i=0, $n=$num_images; $i<$n; $i++) {
  83.     $file = $images_array[$i];
  84.     $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;
  85.     $flag_has_large = true; //file_exists($products_image_large);
  86.     $products_image_large = ($flag_has_large ? $products_image_large : $products_image_directory . $file);
  87.     $flag_display_large = (IMAGE_ADDITIONAL_DISPLAY_LINK_EVEN_WHEN_NO_LARGE == 'Yes' || $flag_has_large);
  88.     $base_image = $products_image_directory . $file;
  89.     $thumb_slashes = zen_image($base_image, addslashes($products_name), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
  90.     // remove additional single quotes from image attributes (important!)
  91.     $thumb_slashes = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
  92.    $thumb_regular = zen_image($base_image, $products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
  93.    $large_link = zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large);
  94.  
  95.    // Link Preparation:
  96.    $script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="javascript:popupWindow(\\\'' . $large_link . '\\\')">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';
  97.  
  98.     $noscript_link = '<noscript>' . ($flag_display_large ? '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large) . '" target="_blank">' . $thumb_regular . '<br /><span class="imgLinkAdditional">' . TEXT_CLICK_TO_ENLARGE . '</span></a>' : $thumb_regular ) . '</noscript>';
  99.  
  100.     //      $alternate_link = '<a href="' . $products_image_large . '" onclick="javascript:popupWindow(\''. $large_link . '\') return false;" title="' . $products_name . '" target="_blank">' . $thumb_regular . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>';
  101.  
  102.     $link = $script_link . "\n      " . $noscript_link;
  103.     //      $link = $alternate_link;
  104.  
  105.     // List Box array generation:
  106.     $list_box_contents[$row][$col] = array('params' => 'class="additionalImages centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
  107.     'text' => "\n      " . $link);
  108.     $col ++;
  109.     if ($col > (IMAGES_AUTO_ADDED -1)) {
  110.       $col = 0;
  111.       $row ++;
  112.     }
  113.   } // end for loop
  114. } // endif