Esempio n. 1
0
 /**
  * Deletes one Record.
  */
 function delete_record($record_id, &$d)
 {
     global $db;
     if (!$this->validate_delete($record_id, $d)) {
         return False;
     }
     /* Delete Image files */
     if (!vmImageTools::process_images($d)) {
         return false;
     }
     $q = "DELETE FROM #__{vm}_vendor where vendor_id='{$record_id}'";
     $db->query($q);
     return True;
 }
Esempio n. 2
0
 /**
  * Deletes one Record.
  */
 function delete_record($record_id, &$d)
 {
     global $ps_product, $db, $vmLogger, $VM_LANG;
     if (!$this->validate_delete($record_id, $d)) {
         return False;
     }
     // Delete all products from that category
     // We must filter out those products that are in more than one category!
     // Case 1: Products are assigned to more than on category
     // so let's only delete the __{vm}_product_category_xref entry
     $q = "CREATE TEMPORARY TABLE IF NOT EXISTS `#__tmp_prod` AS\n            (SELECT * FROM `#__{vm}_product_category_xref` \n            WHERE `category_id`='{$record_id}');";
     $db->query($q);
     $q = "SELECT #__{vm}_product_category_xref.product_id\n          FROM `#__{vm}_product_category_xref`, `#__tmp_prod` \n          WHERE #__{vm}_product_category_xref.product_id=#__tmp_prod.product_id \n            AND #__{vm}_product_category_xref.category_id!='{$record_id}';";
     $db->query($q);
     if ($db->num_rows() > 0) {
         $i = 0;
         $q = "DELETE FROM #__{vm}_product_category_xref WHERE product_id IN (";
         while ($db->next_record()) {
             $q .= "'" . $db->f("product_id") . "'";
             if ($i++ < $db->num_rows() - 1) {
                 $q .= ",";
             }
         }
         $q .= ") AND category_id='{$record_id}'";
         $db->query($q);
     } else {
         // Case 2: Products are assigned to this category only
         $q = "SELECT product_id FROM `#__{vm}_product_category_xref` WHERE `category_id`='{$record_id}';";
         $db->query($q);
         $d['product_id'] = array();
         while ($db->next_record()) {
             $d['product_id'][] = $db->f("product_id");
         }
         $ps_product->delete($d);
     }
     $q = "DELETE FROM #__{vm}_category WHERE category_id='{$record_id}'";
     $db->setQuery($q);
     $db->query();
     $q = "DELETE FROM #__{vm}_category_xref WHERE category_child_id='{$record_id}'";
     $db->setQuery($q);
     $db->query();
     // Delete Image files
     if (!vmImageTools::process_images($d)) {
         return false;
     }
     $vmLogger->info($VM_LANG->_('VM_PRODUCT_CATEGORY_DELETED') . ": {$record_id}.");
     return True;
 }
Esempio n. 3
0
 /**
  * Returns the img tag for the given product image
  *
  * @param string $image The name of the imahe OR the full URL to the image
  * @param string $args Additional attributes for the img tag
  * @param int $resize 
  * (1 = resize the image by using height and width attributes, 
  * 0 = do not resize the image)
  * @param string $path_appendix The path to be appended to IMAGEURL / IMAGEPATH
  * @return The HTML code of the img tag
  */
 function image_tag($image, $args = "", $resize = 1, $path_appendix = 'product', $thumb_width = 0, $thumb_height = 0)
 {
     global $mosConfig_live_site, $mosConfig_absolute_path;
     require_once CLASSPATH . 'imageTools.class.php';
     $border = "";
     if (strpos($args, "border=") === false) {
         $border = 'border="0"';
     }
     $height = $width = 0;
     if ($image != "") {
         // URL
         if (substr($image, 0, 4) == "http") {
             $url = $image;
         } else {
             if (PSHOP_IMG_RESIZE_ENABLE == '1' && $resize == 1) {
                 $url = $mosConfig_live_site . "/components/com_virtuemart/show_image_in_imgtag.php?filename=" . urlencode($image) . "&amp;newxsize=" . PSHOP_IMG_WIDTH . "&amp;newysize=" . PSHOP_IMG_HEIGHT . "&amp;fileout=";
                 if (!strpos($args, "height=")) {
                     $arr = @getimagesize(vmImageTools::getresizedfilename($image, $path_appendix, '', $thumb_height, $thumb_width));
                     $width = $arr[0];
                     $height = $arr[1];
                 }
             } else {
                 $url = IMAGEURL . $path_appendix . '/' . $image;
                 $using_resized_image = false;
                 if ($resize) {
                     $image = vmImageTools::getresizedfilename($image, $path_appendix, '', $thumb_height, $thumb_width);
                     if (file_exists($image)) {
                         $using_resized_image = true;
                     }
                 }
                 if ($resize && !$using_resized_image) {
                     if ($height < $width) {
                         $width = @round($width / ($height / PSHOP_IMG_HEIGHT));
                         $height = PSHOP_IMG_HEIGHT;
                     } else {
                         $height = @round($height / ($width / PSHOP_IMG_WIDTH));
                         $width = PSHOP_IMG_WIDTH;
                     }
                 }
                 if (file_exists($image)) {
                     $url = str_replace($mosConfig_absolute_path, $mosConfig_live_site, $image);
                 } elseif (file_exists($mosConfig_absolute_path . '/' . $image)) {
                     $url = $mosConfig_live_site . '/' . $image;
                 }
                 $url = str_replace('//', '/', $url);
                 $url = str_replace(':/', '://', $url);
                 if (!strpos($args, "height=")) {
                     $f = str_replace(IMAGEURL, IMAGEPATH, $url);
                     if (file_exists($f)) {
                         $arr = getimagesize($f);
                         $width = $arr[0];
                         $height = $arr[1];
                     } else {
                         $width = 100;
                         $height = 100;
                     }
                 }
             }
             $url = str_replace(basename($url), $GLOBALS['VM_LANG']->convert(basename($url)), $url);
         }
     } else {
         $url = VM_THEMEURL . 'images/' . NO_IMAGE;
     }
     return vmCommonHTML::imageTag($url, '', '', $height, $width, '', '', $args . ' ' . $border);
 }
Esempio n. 4
0
 /**
  * Resizes an image
  *
  * @param string $fileName
  * @param string $section
  * @param int $height
  * @param int $width
  * @return string
  */
 function createThumbImage($fileName, $section = 'product', $height = PSHOP_IMG_HEIGHT, $width = PSHOP_IMG_WIDTH)
 {
     require_once CLASSPATH . 'imageTools.class.php';
     /* Generate Image Destination File Name */
     $pathinfo = pathinfo($fileName);
     $to_file_thumb = basename($fileName, '.' . $pathinfo['extension']) . "_" . $height . "x" . $width . "." . $pathinfo['extension'];
     $fileout = IMAGEPATH . "{$section}/resized/" . $to_file_thumb;
     vmImageTools::ResizeImage($fileName, $fileout, $height, $width);
     return $fileout;
 }