/** * Sets the product data to be used to determine certain template options such as start, reserve prices etc. * * @param array $productData */ public function setProductData($productData) { $this->_productData = $productData; // set the item image if (isset($this->_productData['imageid'])) { $image = new ISC_PRODUCT_IMAGE; $image->populateFromDatabaseRow($this->_productData); try { $this->_itemImage = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false); } catch (Exception $exception) { } } }
private function _SetImageData() { $this->_prodid = (int)$_GET['product_id']; // Load the product name $query = sprintf("select prodname from [|PREFIX|]products where productid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($this->GetProductId())); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $this->_prodname = $GLOBALS['ISC_CLASS_DB']->FetchOne($result, "prodname"); // Are we showing the image for a particular variation? if(isset($_GET['variation_id'])) { $this->_variationid = (int)$_GET['variation_id']; $query = "SELECT vcimage, vcimagezoom FROM [|PREFIX|]product_variation_combinations WHERE vcproductid='".$this->_prodid."' AND combinationid='".$this->_variationid."'"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if (!$variation = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { // Invalid variation exit; } if ($variation['vcimage'] && $variation['vcimagezoom']) { // use the product image library to get the url which will trigger a resize if necessary try { $productImage = new ISC_PRODUCT_IMAGE; $productImage->setSourceFilePath($variation['vcimage']); $productImage->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $variation['vcimagezoom']); $this->_variationImage = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false); } catch (Exception $exception) { // nothing } } } // Otherwise, just load general images for a product //else { // Load the images into an array $productImages = ISC_PRODUCT_IMAGE::getProductImagesFromDatabase($this->GetProductId()); if(!empty($productImages)) { $i = 0; foreach ($productImages as $productImage) { $imgDesc = ''; $zoomImg = ''; $tinyImg = ''; $thumbImg = ''; try{ $zoomImg = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); } catch (Exception $exception) { // do nothing, will result in returning blank string, which is fine } try{ $thumbImg = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true); //$GLOBALS['ProductThumbURL'] = $thumbURL; } catch (Exception $exception) { } // if both standard image and zoom image not exist, go to the next image. if($thumbImg == '' && $zoomImg == '') { continue; } try{ $tinyImg = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true); } catch (Exception $exception) { // do nothing, will result in returning blank string, which is fine } $imgDesc = $productImage->getDescription(); if ($imgDesc == '') { $imgIndex= $i+1; $imgDesc = GetLang("Image")." ".$imgIndex; } if($zoomImg!= '' ) { $this->_prodimages['zoom'][] = $zoomImg; //use standard image if zoom image not exist. } else { $this->_prodimages['zoom'][] = $thumbImg; } $this->_prodimages['tiny'][] = $tinyImg; $this->_prodImagesDescriptions[] = $imgDesc; $i++; } //} // How many images are there? $this->_prodnumimages = count($this->_prodimages['zoom']); } // Which image should we show? if(isset($_GET['current_image'])) { $this->_prodcurrentimage = (int)$_GET['current_image']; } elseif(isset($_GET['variation_id'])) { $this->_prodcurrentimage = 'variation'; } }
public function Action_GetProduct() { if(empty($this->router->request->details->productId)) { $this->BadRequest('The details->productId node is missing'); } $image = new ISC_PRODUCT_IMAGE(); // autoload helper so we can use exceptions defined in the product image class file unset($image); $productId = (int)$this->router->request->details->productId; $productClass = new ISC_PRODUCT($productId); $product = $productClass->_product; // stuff that comes directly from the database may be incomplete -- use the image library to make sure try { if (!$product['imageid']) { // no image present in data so throw an exception just to force the removal of data below in the catch{} block throw new ISC_PRODUCT_IMAGE_EXCEPTION(); } $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($product); // call the image library to make sure resized images are present and then add full urls so they're useful for remote users $product['imagefiletiny'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false); $product['imagefilethumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false); $product['imagefilestd'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false); $product['imagefilezoom'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false); // call the image library to make sure resized images are present and the sizes are correct $product['imagefiletinysize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY)); $product['imagefilethumbsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL)); $product['imagefilestdsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD)); $product['imagefilezoomsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM)); } catch (Exception $exception) { // some sort of problem when dealing with product images - remove image info from the response unset( $product['imagefiletiny'], $product['imagefilethumb'], $product['imagefilestd'], $product['imagefilezoom'], $product['imagefiletinysize'], $product['imagefilethumbsize'], $product['imagefilestdsize'], $product['imagefilezoomsize'], $product['imagedesc'], $product['imagedateadded'] ); } // direct data feed also includes some fields that are irrelevant or unwanted unset( $product['imagefile'], // don't provide a link to the non-water-marked image $product['imageprodid'], $product['imageprodhash'], $product['imageisthumb'], $product['imagesort'] ); if(empty($product)) { return array(); } $product['prodlink'] = ProdLink($product['prodname']); // Fetch any images for the product $images = new ISC_PRODUCT_IMAGE_ITERATOR(ISC_PRODUCT_IMAGE::generateGetProductImagesFromDatabaseSql((int)$productId)); foreach ($images as $image) { /** @var $image ISC_PRODUCT_IMAGE */ $imageisthumb = 0; if ($image->getIsThumbnail()) { $imageisthumb = 1; } try { $product['images']['item'][] = array( 'imageid' => $image->getProductImageId(), 'imagefiletiny' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false), 'imagefilethumb' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false), 'imagefilestd' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false), 'imagefilezoom' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false), 'imagefiletinysize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY)), 'imagefilethumbsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL)), 'imagefilestdsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD)), 'imagefilezoomsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM)), 'imageisthumb' => $imageisthumb, 'imagesort' => $image->getSort(), 'imagedesc' => $image->getDescription(), 'imagedateadded' => $image->getDateAdded(), ); } catch (Exception $exception) { // skip this image and bring down the count of product images obtained from ISC_PRODUCT $product['numimages']--; } } // Fetch the categories this product belongs to $trailCategories = array(); $crumbList = array(); $query = " SELECT c.categoryid, c.catparentlist FROM [|PREFIX|]categoryassociations ca JOIN [|PREFIX|]categories c ON (c.categoryid=ca.categoryid) WHERE ca.productId='".(int)$productId."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($row['catparentlist'] == '') { $row['catparentlist'] = $row['categoryid']; } $cats = explode(",", $row['catparentlist']); $trailCategories = array_merge($trailCategories, $cats); $crumbList[$row['categoryid']] = $row['catparentlist']; } $trailCategories = implode(",", array_unique($trailCategories)); $categories = array(); if ($trailCategories != '') { // Now load the names for the parent categories from the database $query = " SELECT categoryid, catname FROM [|PREFIX|]categories WHERE categoryid IN (".$trailCategories.") "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $categories[$row['categoryid']] = $row['catname']; } } // Now we have all of the information we need to build the trails, lets actually build them foreach ($crumbList as $productcatid => $trail) { $cats = explode(',', $trail); $catName = ''; $catLink = CatLink($productcatid, $categories[$productcatid]); foreach ($cats as $categoryid) { if(isset($categories[$categoryid])) { if($catName) { $catName .= ' » '; } $catName .= $categories[$categoryid]; } } $product['categories']['item'][] = array( 'name' => $catName, 'link' => $catLink, 'id' => $productcatid ); } if($product['prodvariationid'] > 0) { if ($product['prodsaleprice'] != 0) { $variationBasePrice = $product['prodsaleprice']; } else { $variationBasePrice = $product['prodprice']; } $vop = $productClass->_prodvariationoptions; $vval = $productClass->_prodvariationvalues; foreach($productClass->_prodvariationcombinations as $variation) { $variationPrice = CurrencyConvertFormatPrice(CalcProductVariationPrice($variationBasePrice, $variation['vcpricediff'], $variation['vcprice'], $product)); $variationWeight = FormatWeight(CalcProductVariationWeight($product['prodweight'], $variation['vcweightdiff'], $variation['vcweight']), true); $variationName = array(); $options = explode(',', $variation['vcoptionids']); foreach($options as $k => $optionId) { $label = $vop[$k]; $variationName[] = $label.': '.$vval[$label][$optionId]; } $variationName = implode(', ', $variationName); $variationRow = array( 'name' => $variationName, 'id' => $variation['combinationid'], 'price' => $variationPrice, 'sku' => $variation['vcsku'], 'weight' => $variationWeight, ); if($product['prodinvtrack'] == 2) { $variationRow['stock'] = $variation['vcstock']; } if ($variation['vcimage']) { try { $image = new ISC_PRODUCT_IMAGE; $image->setSourceFilePath($variation['vcimage']); if($variation['vcimagethumb']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, $variation['vcimagethumb']); $variationRow['thumb'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, false); } if($variation['vcimagestd']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $variation['vcimagestd']); $variationRow['standard'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false); } if($variation['vcimagezoom']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $variation['vcimagezoom']); $variationRow['image'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false); } } catch (Exception $exception) { // nothing } } $product['variations']['item'][] = $variationRow; } } return $product; }
public function WriteRow($row) { $expirationDate = isc_date("Y-m-d", strtotime('+29 days')); $link = ProdLink($row['prodname']); $desc = strip_tags($row['proddesc']); // Strip out invalid characters $desc = StripInvalidXMLChars($desc); if(isc_strlen($desc) > 1000) { $desc = isc_substr($desc, 0, 997)."..."; } // Apply taxes to the price $price = getClass('ISC_TAX')->getPrice($row['prodcalculatedprice'], $row['tax_class_id'], getConfig('taxDefaultTaxDisplayProducts')); $entry = array( 'title' => isc_html_escape($row['prodname']), 'link' => isc_html_escape($link), 'description' => isc_html_escape($desc), 'g:department' => isc_html_escape($row['catname']), 'g:expiration_date' => $expirationDate, 'g:id' => $row['productid'], 'g:condition' => isc_html_escape(isc_strtolower($row['prodcondition'])), 'g:price' => $price ); if($row['brandname']) { $entry['g:brand'] = isc_html_escape($row['brandname']); } if(!empty($row['imagefile'])) { try { $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($row); $entry['g:image_link'] = isc_html_escape($image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false)); } catch (Exception $ex) { } } if($row['prodcode']) { $entry['g:model_number'] = isc_html_escape($row['prodcode']); } if($row['prodweight'] > 0) { if(GetConfig('WeightMeasurement') == 'KGS') { $measure = 'kg'; } else { $measure = strtolower(GetConfig('WeightMeasurement')); } $entry['g:weight'] = FormatWeight($row['prodweight'], false).' '.$measure; } $dimensions = array( 'g:height' => 'prodheight', 'g:length' => 'proddepth', 'g:width' => 'prodwidth' ); if(GetConfig('LengthMeasurement') == 'Centimeters') { $measure = 'cm'; } else { $measure = strtolower(GetConfig('LengthMeasurement')); } foreach($dimensions as $google => $ours) { if($row[$ours] > 0) { $entry[$google] = $row[$ours].' '.$measure; } } // upc codes if(!empty($row['upc'])) { $entry['g:upc'] = StripInvalidXMLChars($row['upc']); } $xml = "<entry>\n"; foreach($entry as $k => $v) { $xml .= "\t<".$k."><![CDATA[".$v."]]></".$k.">\n"; } if(isset($row['prodfreeshipping']) && $row['prodfreeshipping'] != 1){ $xml .= "</entry>\n"; } else { $xml .= "\t<g:shipping><g:price><![CDATA[0]]></g:price></g:shipping>\n</entry>\n"; } fwrite($this->handle, $xml); }
/** * Given a picnik token and a remote file, downloads and processes the remote image, updating and cleaning up local data as required, and sets up template data for displaying to the browser * * @param array $token * @param string $remoteFile * @return bool True on success, false on error - on error, a template variable named 'PicnikError' will be assigned as non-false */ public function receivePicnik($token, $remoteFile) { $this->template->assign('PicnikError', false); $sourceFile = $this->getSourceFileForImage($token['imagetype'], $token['imageid']); if (!$sourceFile) { $this->template->assign('PicnikError', GetLang('PicnikError_NoSourceFile')); return false; } $errorType = null; if (!$this->downloadToFile($remoteFile, $sourceFile, $errorType)) { if ($errorType == 1) { $this->template->assign('PicnikError', GetLang('PicnikError_NoWrite')); } else { $this->template->assign('PicnikError', GetLang('PicnikError_NoDownload')); } return false; } $imageSize = @getimagesize($sourceFile); if (!$imageSize) { $this->template->assign('PicnikError', GetLang('PicnikError_Invalid')); return false; } $callbackData = array(); // the source file has been replaced, now regenerate other files based on it if necessary switch ($token['imagetype']) { case ISC_PICNIK_TYPE_PRODUCTIMAGE: $image = new ISC_PRODUCT_IMAGE((int)$token['imageid']); $image->removeResizedFiles(); $image->saveToDatabase(true); $callbackData['thumbnail'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); $callbackData['zoom'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); break; case ISC_PICNIK_TYPE_IMAGEMANAGER: $callbackData['name'] = basename($sourceFile); $callbackData['size'] = Store_Number::niceSize(filesize($sourceFile)); $callbackData['url'] = GetConfig('ShopPathSSL') . '/' . GetConfig('ImageDirectory') . '/uploaded_images/' . $callbackData['name']; $callbackData['dimensions'] = $imageSize[0] . ' x ' . $imageSize[1]; $callbackData['id'] = md5($callbackData['name']); $callbackData['displaywidth'] = $imageSize[0]; $callbackData['displayheight'] = $imageSize[1]; if ($callbackData['displaywidth'] > 200) { $callbackData['displayheight'] = (200 / $callbackData['displaywidth']) * $callbackData['displayheight']; $callbackData['displaywidth']= 200; } if ($callbackData['displayheight'] > 150) { $callbackData['displaywidth'] = (150/$callbackData['displayheight']) * $callbackData['displaywidth']; $callbackData['displayheight'] = 150; } break; } $this->removeToken($token['picniktokenid']); $this->template->assign('PicnikCallbackData', isc_json_encode($callbackData)); return $callbackData; }
public function ManageProductsGrid(&$numProducts) { // Show a list of products in a table $page = 0; $start = 0; $numProducts = 0; $GLOBALS['ProductGrid'] = ""; $max = 0; // Is this a custom search? if(isset($_GET['searchId'])) { // Override custom search sort fields if we have a requested field if(isset($_GET['sortField'])) { $_REQUEST['sortField'] = $_GET['sortField']; } if(isset($_GET['sortOrder'])) { $_REQUEST['sortOrder'] = $_GET['sortOrder']; } } if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $featuredColumn = 'prodvendorfeatured'; } else { $featuredColumn = 'prodfeatured'; } $validSortFields = array('productid', 'prodcode', 'currentinv', 'prodname', 'prodcalculatedprice', 'prodvisible', $featuredColumn, '_calc_prodstatus'); if(isset($_REQUEST['sortOrder']) && $_REQUEST['sortOrder'] == "asc") { $sortOrder = "asc"; } else { $sortOrder = "desc"; } if(isset($_REQUEST['sortField']) && in_array($_REQUEST['sortField'], $validSortFields)) { $sortField = $_REQUEST['sortField']; SaveDefaultSortField("ManageProducts", $_REQUEST['sortField'], $sortOrder); } else { list($sortField, $sortOrder) = GetDefaultSortField("ManageProducts", "productid", $sortOrder); } if(isset($_GET['page'])) { $page = (int)$_GET['page']; } else { $page = 1; } if (isset($_GET['perpage'])) { $perPage = (int)$_GET['perpage']; SaveDefaultPerPage("ManageProducts", $perPage); } else { $perPage = GetDefaultPerPage("ManageProducts", ISC_PRODUCTS_PER_PAGE); } if(isset($_GET['filterCategory']) && $_GET['filterCategory'] == "-1") { $GLOBALS['FilterLow'] = "selected=\"selected\""; } if(isset($_GET['filterCategory'])) { $filterCat = (int)$_GET['filterCategory']; } else { $filterCat = 0; } if(!gzte11(ISC_MEDIUMPRINT)) { $GLOBALS['ProductNameSpan'] = 3; $GLOBALS['HideInventoryOptions'] = 'none'; } else { $GLOBALS['HideInventoryOptions'] = ''; } // Build the search and sort URL $searchURL = $this->buildSearchUrlData($_GET, $sortField, $sortOrder); $this->buildLetterSearchUrlData($searchURL); $sortURL = $searchURL; unset($sortURL['sortField'], $sortURL['sortOrder']); // Limit the number of questions returned if($page == 1) { $start = 1; } else { $start = ($page * $perPage) - ($perPage-1); } $start = $start-1; // Get the results for the query $product_result = $this->_GetProductList($start, $sortField, $sortOrder, $numProducts, '', $perPage); $GLOBALS['perPage'] = $perPage; $GLOBALS['numProducts'] = $numProducts; $GLOBALS['pageURL'] = "index.php?ToDo=viewProducts&" . http_build_query($searchURL); $GLOBALS['currentPage'] = $page; if (isset($_REQUEST['searchQuery'])) { $query = $_REQUEST['searchQuery']; } else { $query = ''; } $GLOBALS['EscapedQuery'] = isc_html_escape($query); $GLOBALS['SearchQuery'] = isc_html_escape($query); $GLOBALS['SortField'] = $sortField; $GLOBALS['SortOrder'] = $sortOrder; if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $featuredColumn = 'prodvendorfeatured'; } else { $featuredColumn = 'prodfeatured'; } $sortLinks = array( "Code" => "prodcode", "Stock" => "currentinv", "Name" => "prodname", "Price" => "prodcalculatedprice", "Status" => "_calc_prodstatus", "Visible" => "prodvisible", "Featured" => $featuredColumn ); BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewProducts&".http_build_query($sortURL)."&page=".$page, $sortField, $sortOrder); // Workout the maximum size of the array $max = $start + $perPage; if ($max > $numProducts) { $max = $numProducts; } if($numProducts > 0) { // Display the products while($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($product_result)) { if ($row['prodcode'] == "") { $GLOBALS['SKU'] = GetLang('NA'); } else { $GLOBALS['SKU'] = isc_html_escape($row['prodcode']); } $GLOBALS['ProductId'] = (int)$row['productid']; $GLOBALS['Name'] = sprintf("<a title='%s' class='Action' href='%s' target='_blank'>%s</a>", GetLang('ProductView'), ProdLink($row['prodname']), isc_html_escape($row['prodname'])); // Do we need to show product thumbnails? if(GetConfig('ShowThumbsInControlPanel')) { if ($row['imageid'] !== null) { $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($row); try { $imageThumbnailUrl = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true); $imageDimensions = $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY); $GLOBALS['ProductImage'] = sprintf('<img src="%1$s" width="%2$d" height="%3$d" />', isc_html_escape($imageThumbnailUrl), $imageDimensions[0], $imageDimensions[1]); } catch (Exception $exception) { // source image is not readable, show the no image placeholder $GLOBALS['ProductImage'] = sprintf("<div class='NoThumb'>%s<br />%s<br />%s</div>", GetLang('NoImage1'), GetLang('NoImage2'), GetLang('NoImage3')); } } else { $GLOBALS['ProductImage'] = sprintf("<div class='NoThumb'>%s<br />%s<br />%s</div>", GetLang('NoImage1'), GetLang('NoImage2'), GetLang('NoImage3')); } } else { // Use JavaScript to hide the thumbnail field $GLOBALS['HideThumbnailField'] = "1"; } $GLOBALS['Price'] = FormatPrice($row['prodcalculatedprice']); $GLOBALS['StockExpand'] = " "; $GLOBALS['LowStockStyle'] = ""; if ($row['prodinvtrack'] == 0) { $GLOBALS['StockInfo'] = GetLang('NA'); } else if($row['prodinvtrack'] > 0) { $GLOBALS['StockExpand'] = sprintf("<a href=\"#\" onclick=\"ShowStock('%d', '%d', '%d'); return false;\"><img id=\"expand%d\" src=\"images/plus.gif\" align=\"left\" class=\"ExpandLink\" width=\"19\" height=\"16\" title=\"%s\" border=\"0\"></a>", $row['productid'], $row['prodinvtrack'], $row['prodvariationid'], $row['productid'], GetLang('ClickToViewStock')); $percent = 0; if($row['prodlowinv'] > 0) { $percent = ceil(($row['currentinv'] / ($row['prodlowinv'] * 2)) * 100); } elseif ($row['currentinv'] > 0) { $percent = 100; } if($percent > 100) { $percent = 100; } if($percent > 75) { $stockClass = 'InStock'; $orderMore = GetLang('SNo'); } else if($percent > 50) { $stockClass = 'StockWarning'; $orderMore = GetLang('Soon'); } else { $stockClass = 'LowStock'; $orderMore = GetLang('SYes'); } $width = ceil(($percent/100)*72); $stockInfo = sprintf(GetLang('CurrentStockLevel').': %s<br />'.GetLang('LowStockLevel1').': %s<br />'.GetLang('OrderMore').': '.$orderMore, $row['currentinv'], $row['prodlowinv'], $orderMore); $GLOBALS['StockInfo'] = sprintf("<div class=\"StockLevelIndicator\" onmouseover=\"ShowQuickHelp(this, '%s', '%s')\" onmouseout=\"HideQuickHelp(this)\"><span class=\"%s\" style=\"width: %spx\"></span></div>", GetLang('StockLevel'), $stockInfo, $stockClass, $width); } // If they have permission to edit products, they can change // the visibility status of a product by clicking on the icon if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Products)) { if ($row['prodvisible'] == 1) { $GLOBALS['Visible'] = sprintf("<a title='%s' href='index.php?ToDo=editProductVisibility&prodId=%d&visible=0' onclick=\"quickToggle(this, 'visible'); return false;\"><img border='0' src='images/tick.gif' alt='tick'></a>", GetLang('ClickToHide'), $row['productid']); } else { $GLOBALS['Visible'] = sprintf("<a title='%s' href='index.php?ToDo=editProductVisibility&prodId=%d&visible=1' onclick=\"quickToggle(this, 'visible'); return false;\"><img border='0' src='images/cross.gif' alt='cross'></a>", GetLang('ClickToShow'), $row['productid']); } } else { if ($row['prodvisible'] == 1) { $GLOBALS['Visible'] = '<img border="0" src="images/tick.gif" alt="tick">'; } else { $GLOBALS['Visible'] = '<img border="0" src="images/cross.gif" alt="cross">'; } } // If they have permission to edit products, they can change // the featured status of a product by clicking on the icon if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $featuredColumn = 'prodvendorfeatured'; } else { $featuredColumn = 'prodfeatured'; } if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Products)) { if ($row[$featuredColumn] == 1) { $GLOBALS['Featured'] = sprintf("<a title='%s' href='index.php?ToDo=editProductFeatured&prodId=%d&featured=0' onclick=\"quickToggle(this, 'featured'); return false;\"><img border='0' src='images/tick.gif' alt='tick'></a>", GetLang('ClickToHide'), $row['productid']); } else { $GLOBALS['Featured'] = sprintf("<a title='%s' href='index.php?ToDo=editProductFeatured&prodId=%d&featured=1' onclick=\"quickToggle(this, 'featured'); return false;\"><img border='0' src='images/cross.gif' alt='cross'></a>", GetLang('ClickToShow'), $row['productid']); } } else { if ($row[$featuredColumn] == 1) { $GLOBALS['Featured'] = '<img border="0" src="images/tick.gif" alt="tick">'; } else { $GLOBALS['Featured'] = '<img border="0" src="images/cross.gif" alt="cross">'; } } // Workout the edit link -- do they have permission to do so? if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Products)) { $GLOBALS['EditProductLink'] = sprintf("<a title='%s' class='Action' href='index.php?ToDo=editProduct&productId=%d'>%s</a>", GetLang('ProductEdit'), $row['productid'], GetLang('Edit')); } else { $GLOBALS['EditProductLink'] = sprintf("<a class='Action' disabled>%s</a>", GetLang('Edit')); } $allowpurchases = (int)$row['prodallowpurchases']; $prodpreorder = (int)$row['prodpreorder']; $status = GetLang('CatalogueOnly'); if ($allowpurchases) { if ($prodpreorder) { $status= GetLang('PreOrder'); } else { $status = GetLang('Selling'); } } $GLOBALS['Status'] = $status; $GLOBALS['CopyProductLink'] = "<a title='".GetLang('ProductCopy')."' class='Action' href='index.php?ToDo=copyProduct&productId=".$row['productid']."'>".GetLang('Copy')."</a>"; $GLOBALS['ProductGrid'] .= $this->template->render('product.manage.row.tpl'); } } if($GLOBALS['ProductGrid'] == '') { if(isset($_REQUEST['letter'])) { $GLOBALS['ProductGrid'] = sprintf('<tr> <td colspan="11" style="padding:10px"><em>%s</em></td> </tr>', sprintf(GetLang('LetterSortNoResults'), isc_strtoupper($_REQUEST['letter']))); } } return $this->template->render('products.manage.grid.tpl'); }
/** * Get the thumbnail image of this quote item. * * @return string Thumbnail image path. */ public function getThumbnail() { $productData = $this->getProductData(); if (!empty($productData['variation']['vcimage']) && !empty($productData['variation']['vcimagethumb'])) { try { $image = new ISC_PRODUCT_IMAGE; $image->setSourceFilePath($productData['variation']['vcimage']); $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, $productData['variation']['vcimagethumb']); return $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, false); } catch (Exception $exception) { return ''; } } try { $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($productData); return $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); } catch (Exception $exception) { return ''; } }
/** * Gets a set of images for the first option set in a variation for a specific product. * Eg. For a variation: Color => (Red, Blue, Green), Size => (S, M, L) : * Red => ../image1.jpg * Blue => ../image2.jpg * Green => ../image3.jpg * will be returned. * * @param int $productId The product to find images for * @param int $variationId The variation to find images for * @return array An array of combination images indexed by option name */ public static function getCombinationImagesForFirstOption($productId, $variationId) { // get the variation options for the first option set $query = " SELECT * FROM [|PREFIX|]product_variation_options WHERE vovariationid = " . $variationId . " AND vooptionsort = 1 "; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); $optionIdsArray = array(); $optionName = ''; while ($optionRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { $optionName = $optionRow['voname']; $optionIdsArray[$optionRow['voptionid']] = $optionRow['vovalue']; } // now find a set of images for the options $setMatches = array(); foreach($optionIdsArray as $optionId => $optionValue) { $setMatches[] = 'FIND_IN_SET(' . $optionId . ', vcoptionids)'; } $query = " SELECT vcoptionids, vcimage, vcimagestd FROM [|PREFIX|]product_variation_combinations WHERE vcvariationid = " . $variationId . " AND vcproductid = " . $productId . " AND vcenabled = 1 AND ( " . implode(' OR ', $setMatches) . " ) AND vcimage != '' AND vcimagestd != '' "; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); $images = array(); while ($comboRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { $comboOptionIds = explode(',', $comboRow['vcoptionids']); // get the option id that was matched for this row $optionId = current(array_intersect(array_keys($optionIdsArray), $comboOptionIds)); // get the option that this row corresponds to $optionName = $optionIdsArray[$optionId]; if (!isset($images[$optionName])) { try { $productImage = new ISC_PRODUCT_IMAGE; $productImage->setSourceFilePath($comboRow['vcimage']) ->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $comboRow['vcimagestd']); $images[$optionName] = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false); } catch (Exception $exception) { // nothing } } } return $images; }
/** * Build the HTML for the thumbnail image of a product. * * @todo refactor * @param string The filename of the thumbnail. * @param string The URL that the thumbnail should link to. * @param string The optional target for the link. * @return string The built HTML for the thumbnail. */ function ImageThumb($imageData, $link='', $target='', $class='') { $altText = ""; if(!is_array($imageData)) { $thumb = $imageData; } else { $image = new ISC_PRODUCT_IMAGE; $image->populateFromDatabaseRow($imageData); $altText = $image->getDescription(); if(empty($altText) && !empty($imageData['prodname'])) { $altText = $imageData['prodname']; } try { $thumb = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); } catch (Exception $exception) { $thumb = ''; } unset($image); } if(!$thumb) { switch(GetConfig('DefaultProductImage')) { case 'template': $thumb = $GLOBALS['IMG_PATH'].'/ProductDefault.gif'; break; case '': $thumb = ''; break; default: $thumb = GetConfig('ShopPath').'/'.GetConfig('DefaultProductImage'); } } /* else { $thumbPath = APP_ROOT.'/'.GetConfig('ImageDirectory').'/'.$thumb; $thumb = $GLOBALS['ShopPath'].'/'.GetConfig('ImageDirectory').'/'.$thumb; } */ if(!$thumb) { return ''; } if($target != '') { $target = 'target="'.$target.'"'; } if($class != '') { $class = 'class="'.$class.'"'; } $imageThumb = ''; if($link != '') { $imageThumb .= '<a href="'.$link.'" '.$target.' '.$class.'>'; } $imageSize = @getimagesize($thumbPath); if(is_array($imageSize) && !empty($imageSize)) { $imageThumb .= '<img src="'.$thumb.'" alt="'.$altText.'" ' . $imageSize[3] . ' />'; }else{ $imageThumb .= '<img src="'.$thumb.'" alt="'.$altText.'" />'; } if($link != '') { $imageThumb .= '</a>'; } return $imageThumb; }
/** * Build the array of searched item results for the AJAX request * * Method will build an array of searched item results for the AJAX request. Method will work with the ISC_SEARCH * class to get the results so make sure that the object is initialised and the DoSearch executed. * * Each key in the array will be the 'score' value (as a string) so it can be merged in with other results and can * then be further sorted using any PHP array sorting functions, so output would be something like this: * * EG: return = array(10, // result count * array( * "12.345" => array( * 0 => [product HTML] * 1 => [product HTML] * 2 => [product HTML] * ), * "2.784" => array( * 0 => [product HTML] * ), * "6.242" => array( * 0 => [product HTML] * 1 => [product HTML] * ) * ) * ); * * @access public * @return array An array with two values, first is total number of search results. Other is the search item results AJAX array on success, empty array on error */ static public function buildSearchResultsAJAX() { if (!isset($GLOBALS["ISC_CLASS_SEARCH"]) || !is_object($GLOBALS["ISC_CLASS_SEARCH"])) { return array(0, array()); } $totalRecords = $GLOBALS["ISC_CLASS_SEARCH"]->GetNumResults("product"); if ($totalRecords == 0) { return array(0, array()); } $results = $GLOBALS["ISC_CLASS_SEARCH"]->GetResults("product"); $ajaxArray = array(); if (!array_key_exists("results", $results) || !is_array($results["results"])) { return array(); } $products = $results["results"]; foreach ($products as $product) { if (!isset($product["score"])) { $product["score"] = 0; } $GLOBALS["ProductName"] = $product["prodname"]; $GLOBALS["ProductURL"] = ProdLink($product["prodname"]); $GLOBALS['ProductPrice'] = ''; if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) { $GLOBALS['ProductPrice'] = formatProductCatalogPrice($product); } if(getProductReviewsEnabled()) { $ratingURL = $GLOBALS["IMG_PATH"] . "/IcoRating" . (int)$product["prodavgrating"] . ".gif"; $GLOBALS["ProductRatingImage"] = "<img src=\"" . $ratingURL . "\" class=\"RatingIMG\" />"; } else { $GLOBALS["ProductRatingImage"] = ""; } $GLOBALS["ProductNoImageClassName"] = ""; if (isset($product["imageid"]) && $product["imageid"] !== "") { $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($product); $productImageSize = $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY, true); if ($productImageSize[0] > 70) { // ISCFIVEFIVEBETA-89 - cap to 70px wide // note: will need to adjust height by proper ratio if we want the height output to html $productImageSize[0] = 70; } $GLOBALS["ProductImage"] = "<img src=\"" . isc_html_escape($image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true)) . "\" alt=\"" . isc_html_escape($product["prodname"]) . "\" title=\"" . isc_html_escape($product["prodname"]) . "\" width=\"" . $productImageSize[0] . "\" />"; } else { $GLOBALS["ProductNoImageClassName"] = "QuickSearchResultNoImage"; $GLOBALS["ProductImage"] = "<span>" . GetLang("QuickSearchNoImage") . "</span>"; } $sortKey = (string)$product["score"]; if (!array_key_exists($sortKey, $ajaxArray) || !is_array($ajaxArray[$sortKey])) { $ajaxArray[$sortKey] = array(); } $ajaxArray[$sortKey][] = $GLOBALS["ISC_CLASS_TEMPLATE"]->GetSnippet("SearchResultAJAXProduct"); } return array($totalRecords, $ajaxArray); }
private function getOrderData($orderRow, $addressIndex) { // Get the customer data if ($orderRow['ordcustid'] == 0){ $customerData = array( 'CustomerID' => -1, 'Phone' => $orderRow['ordbillphone'], 'Email' => $orderRow['ordbillemail'] ); } else { $customer = GetCustomer($orderRow['ordcustid']); $customerData = array( 'CustomerID' => $orderRow['ordcustid'], 'Phone' => $customer['custconphone'], 'Email' => $customer['custconemail'] ); } $orderId = $orderRow['orderid']; if ($orderRow['shipping_address_count'] > 1) { $orderId .= '-' . $addressIndex; } $data = array( 'OrderNumber' => $orderId, 'OrderDate' => gmdate('Y-m-d H:i:s', $orderRow['orddate']), 'LastModified' => gmdate('Y-m-d H:i:s', $orderRow['ordlastmodified']), 'LastModifiedLocal' => isc_date('Y-m-d H:i:s', $orderRow['ordlastmodified']), 'ShippingMethod' => $orderRow['method'], 'StatusCode' => $orderRow['ordstatus'], 'CustomerComment' => $orderRow['ordcustmessage'], 'Customer' => $customerData, 'ShipAddress' => array( 'Name' => $orderRow['first_name'] . ' ' . $orderRow['last_name'], 'Company' => $orderRow['company'], 'Street1' => $orderRow['address_1'], 'Street2' => $orderRow['address_2'], 'Street3' => '', 'City' => $orderRow['city'], 'PostalCode'=> $orderRow['zip'], 'State' => $orderRow['state'], 'Country' => $orderRow['country_iso2'] ), 'BillAddress' => array( 'Name' => $orderRow['ordbillfirstname'] . ' ' . $orderRow['ordbilllastname'], 'Company' => $orderRow['ordbillcompany'], 'Street1' => $orderRow['ordbillstreet1'], 'Street2' => $orderRow['ordbillstreet2'], 'Street3' => '', 'City' => $orderRow['ordbillsuburb'], 'PostalCode'=> $orderRow['ordbillzip'], 'State' => $orderRow['ordbillstate'], 'Country' => $orderRow['ordbillcountrycode'] ), 'Payment' => array( 'Method' => $orderRow['orderpaymentmethod'], ), ); $incTaxPrices = false; if (GetConfig('taxDefaultTaxDisplayOrders') != TAX_PRICES_DISPLAY_EXCLUSIVE) { $incTaxPrices = true; } // get the products for the order $items = array(); $totalWrapCost = 0; $query = ' SELECT op.*, pi.* FROM [|PREFIX|]order_products op LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageprodid = op.ordprodid AND pi.imageisthumb = 1) WHERE op.order_address_id = ' . $orderRow['address_id']; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($productRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { $item = array( 'ItemID' => $productRow['orderprodid'], 'ProductID' => $productRow['ordprodid'], 'Code' => $productRow['ordprodsku'], 'Name' => $productRow['ordprodname'], 'Quantity' => $productRow['ordprodqty'], 'Weight' => ConvertWeight($productRow['ordprodweight'], 'lbs'), ); if ($incTaxPrices) { $item['UnitPrice'] = $productRow['price_inc_tax']; $totalWrapCost += $productRow['wrapping_cost_inc_tax'] * $productRow['ordprodqty']; } else { $item['UnitPrice'] = $productRow['price_ex_tax']; $totalWrapCost += $productRow['wrapping_cost_ex_tax'] * $productRow['ordprodqty']; } try { $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($productRow); $item['Image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); } catch (Exception $ex) { } $items['Item'][] = $item; } $data['Items'] = $items; // get the totals $totals = array(); $totalID = 1; // gift wrapping cost if ($totalWrapCost > 0) { $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksGiftWrapping'), 'Text' => FormatPrice($totalWrapCost), 'Value' => $totalWrapCost, 'Class' => 'Adjust' ); $totals['Total'][] = $total; } // shipping cost if ($orderRow['shipping_cost_ex_tax'] > 0) { if ($incTaxPrices) { $shippingCost = $orderRow['shipping_cost_inc_tax']; } else { $shippingCost = $orderRow['shipping_cost_ex_tax']; } $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksShipping'), 'Text' => FormatPrice($shippingCost), 'Value' => $shippingCost, 'Class' => 'Shipping' ); $totals['Total'][] = $total; } // handling cost if ($orderRow['handling_cost_ex_tax'] > 0) { if ($incTaxPrices) { $handlingCost = $orderRow['handling_cost_inc_tax']; } else { $handlingCost = $orderRow['handling_cost_ex_tax']; } $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksHandling'), 'Text' => FormatPrice($handlingCost), 'Value' => $handlingCost, 'Class' => 'Shipping' ); $totals['Total'][] = $total; } // tax (not included in total) if ($orderRow['total_tax'] > 0 && !$incTaxPrices) { $total = array( 'TotalID' => $totalID++, 'Name' => 'Tax', 'Text' => FormatPrice($orderRow['total_tax']), 'Value' => $orderRow['total_tax'], 'Class' => 'Tax' ); $totals['Total'][] = $total; } // total if ($incTaxPrices) { $orderTotal = $orderRow['total_inc_tax']; } else { $orderTotal = $orderRow['total_ex_tax']; } $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksTotal'), 'Text' => FormatPrice($orderTotal), 'Value' => $orderTotal, 'Class' => 'ot_total' ); $totals['Total'][] = $total; // gift certificates if ($orderRow['ordgiftcertificateamount'] > 0) { $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksGiftCertificates'), 'Text' => FormatPrice($orderRow['ordgiftcertificateamount']), 'Value' => $orderRow['ordgiftcertificateamount'] * -1, 'Class' => 'Adjust' ); $totals['Total'][] = $total; } // other discount amount if ($orderRow['orddiscountamount'] > 0) { $total = array( 'TotalID' => $totalID++, 'Name' => GetLang('ShipWorksDiscounts'), 'Text' => FormatPrice($orderRow['orddiscountamount']), 'Value' => $orderRow['orddiscountamount'] * -1, 'Class' => 'Adjust' ); $totals['Total'][] = $total; } $data['Totals'] = $totals; return $data; }
public function imagelinkFilter($v, $args=null) { if(!$v['imagefile']) return null; $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($v); try { $url = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false); return $url; } catch(Exception $e) { return null; } }
private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms=array()) { $this->_SetFeedDetails(); $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int)GetConfig('RSSCacheTime')*60); $channel = array( "title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath'], 'namespaces' => array( 'isc' => array( //'http://dtd.interspire.com/rss/isc-1.0.dtd', '', array( 'store_title' => getConfig('StoreName') ) ) ) ); $feed->SetChannel($channel); // The magical Unreal Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function $searchterms = BuildProductSearchTerms($searchTerms); $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder); // Run the query $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int)GetConfig('RSSItemsLimit')); $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(isc_strlen($product['proddesc']) > 300) { $product['proddesc'] = isc_substr($product['proddesc'], 0, 298).".."; } $item = array( 'title' => $product['prodname'], 'date' => $product['proddateadded'], 'link' => prodLink($product['prodname']), 'namespaces' => array( 'isc' => array( 'description' => $product['proddesc'], 'productid' => $product['productid'], ) ) ); if($product['imagefile']) { $thumb = ImageThumb($product, ProdLink($product['prodname'])); $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", $thumb, $product['proddesc']); $image = new ISC_PRODUCT_IMAGE; $image->populateFromDatabaseRow($product); try { $item['namespaces']['isc']['thumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); } catch (Exception $exception) { } try { $item['namespaces']['isc']['image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); } catch (Exception $exception) { } unset ($image); } // Determine the price of this product $price = ''; if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) { $calcPrice = $product['prodcalculatedprice']; $plainPrice = formatProductPrice($product, $calcPrice, array( 'strikeRetail' => false, 'displayInclusive' => getConfig('taxDefaultTaxDisplayCatalog') )); if($plainPrice) { $item['namespaces']['isc']['price'] = $plainPrice; $price = '<strong>'.getLang('Price').': '.$plainPrice.'</strong>'; } } if(GetConfig('ShowProductRating')) { $ratingImage = $GLOBALS['IMG_PATH'].'/IcoRating'.(int)$product['prodavgrating'].'.gif'; $item['namespaces']['isc']['rating'] = (int)$product['prodavgrating']; $item['namespaces']['isc']['rating_image'] = $ratingImage; $ratingImage = '<img src="'.$ratingImage.'" alt="" />'; } else { $ratingImage = ''; } $product['proddesc'] .= '<p>'.$price.' '.$ratingImage.'</p>'; $item['description'] = $product['proddesc']; $feed->AddItem($item); } // Send the feed to the browser $feed->OutputFeed(); }