本文整理汇总了PHP中Products::get_image_array_from_base64方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::get_image_array_from_base64方法的具体用法?PHP Products::get_image_array_from_base64怎么用?PHP Products::get_image_array_from_base64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::get_image_array_from_base64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view_product_overview
//.........这里部分代码省略.........
}
} else {
// TODO: There are other cases of flag combinations that are not indivuidually
// handled here yet.
if ($term == '') {
if ($flagSpecialoffer == Products::DEFAULT_VIEW_DISCOUNTS) {
self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', $_ARRAYLANG['TXT_SHOP_PRODUCTS_SPECIAL_OFFER']);
} else {
if (self::$objTemplate->blockExists('products_in_category')) {
self::$objTemplate->hideBlock('products_in_category');
}
}
} else {
self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', sprintf($_ARRAYLANG['TXT_SHOP_PRODUCTS_SEARCH_RESULTS'], contrexx_raw2xhtml($term)));
}
}
$uri = '&section=Shop' . MODULE_INDEX . $pagingCmd . $pagingCatId . $pagingManId . $pagingTerm;
self::$objTemplate->setVariable(array('SHOP_PRODUCT_PAGING' => \Paging::get($uri, '', $count, $limit, $count > 0), 'SHOP_PRODUCT_TOTAL' => $count));
// Global microdata: Seller information
$seller_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')->toString();
$seller_name = \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop');
if (empty($seller_name)) {
$seller_name = $seller_url;
}
self::$objTemplate->setVariable(array('SHOP_SELLER_NAME' => $seller_name, 'SHOP_SELLER_URL' => $seller_url));
$formId = 0;
$arrDefaultImageSize = $arrSize = null;
foreach ($arrProduct as $objProduct) {
if (!empty($product_id)) {
self::$pageTitle = $objProduct->name();
}
$id = $objProduct->id();
$productSubmitFunction = '';
$arrPictures = Products::get_image_array_from_base64($objProduct->pictures());
$havePicture = false;
$arrProductImages = array();
foreach ($arrPictures as $index => $image) {
$thumbnailPath = $pictureLink = '';
if (empty($image['img']) || $image['img'] == ShopLibrary::noPictureName) {
// We have at least one picture on display already.
// No need to show "no picture" three times!
if ($havePicture) {
continue;
}
$thumbnailPath = self::$defaultImage;
$pictureLink = '#';
//"javascript:alert('".$_ARRAYLANG['TXT_NO_PICTURE_AVAILABLE']."');";
if (empty($arrDefaultImageSize)) {
$arrDefaultImageSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . self::$defaultImage);
self::scaleImageSizeToThumbnail($arrDefaultImageSize);
}
$arrSize = $arrDefaultImageSize;
} else {
$thumbnailPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . \ImageManager::getThumbnailFilename($image['img']);
if ($image['width'] && $image['height']) {
$pictureLink = contrexx_raw2encodedUrl(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . $image['img']) . '" rel="shadowbox[' . ($formId + 1) . ']';
// Thumbnail display size
$arrSize = array($image['width'], $image['height']);
} else {
$pictureLink = '#';
if (!file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath)) {
continue;
}
$arrSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath);
}
self::scaleImageSizeToThumbnail($arrSize);
示例2: view
/**
* The Cart view
*
* Mind that the Cart needs to be {@see update()}d before calling this
* method.
* @global array $_ARRAYLANG Language array
* @param \Cx\Core\Html\Sigma $objTemplate The optional Template
*/
static function view($objTemplate = null)
{
global $_ARRAYLANG;
if (!$objTemplate) {
// TODO: Handle missing or empty Template, load one
die("Cart::view(): ERROR: No template");
// return false;
}
$objTemplate->setGlobalVariable($_ARRAYLANG);
$i = 0;
if (count(self::$products)) {
foreach (self::$products as $arrProduct) {
$groupCountId = $arrProduct['group_id'];
$groupArticleId = $arrProduct['article_id'];
$groupCustomerId = 0;
if (Shop::customer()) {
$groupCustomerId = Shop::customer()->group_id();
}
Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
// product image
$arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
$shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
$thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
foreach ($arrProductImg as $productImg) {
if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
$thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
break;
}
}
/* UNUSED (and possibly obsolete, too)
if (isset($arrProduct['discount_string'])) {
//DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
$objTemplate->setVariable(
'SHOP_DISCOUNT_COUPON_STRING',
$arrProduct['coupon_string']
);
}*/
// The fields that don't apply have been set to ''
// (empty string) already -- see update().
$objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '"', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
//DBG::log("Attributes String: {$arrProduct['options_long']}");
if ($arrProduct['options_long']) {
$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
}
if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
}
if (Vat::isEnabled()) {
$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . ' ' . Currency::getActiveCurrencySymbol()));
}
if (intval($arrProduct['minimum_order_quantity']) > 0) {
$objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
} else {
if ($objTemplate->blockExists('orderQuantity')) {
$objTemplate->hideBlock('orderQuantity');
}
if ($objTemplate->blockExists('minimumOrderQuantity')) {
$objTemplate->hideBlock('minimumOrderQuantity');
}
}
$objTemplate->parse('shopCartRow');
}
} else {
$objTemplate->hideBlock('shopCart');
if ($objTemplate->blockExists('shopCartEmpty')) {
$objTemplate->touchBlock('shopCartEmpty');
$objTemplate->parse('shopCartEmpty');
}
if ($_SESSION['shop']['previous_product_ids']) {
$ids = $_SESSION['shop']['previous_product_ids']->toArray();
Shop::view_product_overview($ids);
}
}
$objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
// Show the Coupon code field only if there is at least one defined
if (Coupon::count_available()) {
//DBG::log("Coupons available");
$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
if ($objTemplate->blockExists('shopCoupon')) {
$objTemplate->parse('shopCoupon');
}
if (self::get_discount_amount()) {
$total_discount_amount = self::get_discount_amount();
//DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
}
}
if (Vat::isEnabled()) {
$objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . ' ' . Currency::getActiveCurrencySymbol()));
if (Vat::isIncluded()) {
$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . ' ' . Currency::getActiveCurrencySymbol()));
}
//.........这里部分代码省略.........
示例3: getPictureByCategoryId
/**
* Returns the first matching picture name found in the Products
* within the Shop Category given by its ID.
* @global ADONewConnection $objDatabase Database connection object
* @param type $category_id
* @return string The image name, or the
* empty string.
* @static
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getPictureByCategoryId($category_id)
{
global $objDatabase;
$category_id = intval($category_id);
$query = "\n SELECT `picture`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_products`\n WHERE FIND_IN_SET({$category_id}, `category_id`)\n AND `picture`!=''\n ORDER BY `ord` ASC";
$objResult = $objDatabase->SelectLimit($query, 1);
if ($objResult && $objResult->RecordCount() > 0) {
// Got a picture
$arrImages = Products::get_image_array_from_base64($objResult->fields['picture']);
$imageName = $arrImages[1]['img'];
return $imageName;
}
// No picture found here
return '';
}
示例4: store_product
//.........这里部分代码省略.........
if ($product_id) {
$objProduct = Product::getById($product_id);
}
$new = false;
if (!$objProduct) {
$new = true;
$objProduct = new Product($product_code, $category_id, $product_name, $distribution, $customer_price, $active, 0, $weight);
if (!$objProduct->store()) {
return \Message::error($_ARRAYLANG['TXT_SHOP_PRODUCT_ERROR_STORING']);
}
// $product_id = $objProduct->id();
}
// Apply the changes to all Products with the same Product code.
// Note: This is disabled for the time being, as virtual categories are, too.
// if ($product_code != '') {
// $arrProduct = Products::getByCustomId($product_code);
// } else {
// $arrProduct = array($objProduct);
// }
// if (!is_array($arrProduct)) return false;
// foreach ($arrProduct as $objProduct) {
// Update each product
$objProduct->code($product_code);
// NOTE: Only change the parent ShopCategory for a Product
// that is in a real ShopCategory.
$objProduct->category_id($category_id);
$objProduct->name($product_name);
$objProduct->distribution($distribution);
$objProduct->price($customer_price);
$objProduct->active($active);
// On the overview only: $objProduct->ord();
$objProduct->weight($weight);
$objProduct->resellerprice($reseller_price);
$objProduct->discount_active($discount_active);
$objProduct->discountprice($discount_price);
$objProduct->vat_id($vat_id);
$objProduct->short($short);
$objProduct->long($long);
$objProduct->stock($stock);
$objProduct->minimum_order_quantity($minimum_order_quantity);
$objProduct->stock_visible($stock_visible);
$objProduct->uri($uri);
$objProduct->b2b($b2b);
$objProduct->b2c($b2c);
$objProduct->date_start($date_start);
$objProduct->date_end($date_end);
$objProduct->manufacturer_id($manufacturer_id);
$objProduct->pictures($imageName);
// Currently not used on the detail page
// $objProduct->flags($flags);
$objProduct->usergroup_ids($usergroup_ids);
$objProduct->group_id($discount_group_count_id);
$objProduct->article_id($discount_group_article_id);
$objProduct->keywords($keywords);
//DBG::log("ShopManager::store_product(): Product: reseller_price ".$objProduct->resellerprice());
// Remove old Product Attributes.
// They are re-added below.
$objProduct->clearAttributes();
// Add current product attributes
if (isset($_POST['options']) && is_array($_POST['options'])) {
foreach ($_POST['options'] as $valueId => $nameId) {
$order = intval($_POST['productOptionsSortId'][$nameId]);
$objProduct->addAttribute(intval($valueId), $order);
}
}
// Mind that this will always be an *update*, see the call to
// store() above.
if (!$objProduct->store()) {
return \Message::error($_ARRAYLANG['TXT_SHOP_PRODUCT_ERROR_STORING']);
}
// }
// Add/remove Categories and Products to/from
// virtual ShopCategories.
// Note that this *MUST* be called *AFTER* the Product is updated
// or inserted.
// Virtual categories are disabled for the time being
// Products::changeFlagsByProductCode(
// $product_code, $flags
// );
$objImage = new \ImageManager();
$arrImages = Products::get_image_array_from_base64($imageName);
// Create thumbnails if not available, or update them
foreach ($arrImages as $arrImage) {
if (!empty($arrImage['img']) && $arrImage['img'] != ShopLibrary::noPictureName) {
if (!$objImage->_createThumbWhq(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/', \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/', $arrImage['img'], \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality', 'Shop'))) {
\Message::error(sprintf($_ARRAYLANG['TXT_SHOP_COULD_NOT_CREATE_THUMBNAIL'], $arrImage['img']));
}
}
}
\Message::ok($new ? $_ARRAYLANG['TXT_DATA_RECORD_ADDED_SUCCESSFUL'] : $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']);
switch ($_POST['afterStoreAction']) {
case 'newEmpty':
\Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products&tpl=manage');
case 'newTemplate':
\Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products&tpl=manage&id=' . $objProduct->id() . '&new=1');
}
\Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products');
// Never reached
return true;
}