本文整理汇总了PHP中Image::getImages方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getImages方法的具体用法?PHP Image::getImages怎么用?PHP Image::getImages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::getImages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
parent::initContent();
$id = $_GET['id'];
$id_lang = $this->context->language->id;
$product = new Product((int) $id);
$link = new Link();
$url = $link->getProductLink($product);
$features = Db::getInstance()->ExecuteS('
SELECT fl.name feature_name, fvl.value feature_value
FROM ' . _DB_PREFIX_ . 'feature_product fp
LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' )
LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ')
WHERE fp.id_product=' . $id);
// print_r($features);
$images = Image::getImages((int) $id_lang, (int) $product->id);
//Limitamos el numero de fotos a cuatro solamente
while (count($images) > 3) {
$var = array_pop($images);
}
$this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND')));
$html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl');
$dompdf = new DOMPDF();
$dompdf->set_option('enable_remote', TRUE);
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();
$dompdf->stream('producto');
//$this->setTemplate('custom_template_content.tpl');
//file_put_contents($filename, $dompdf->output());
//$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty);
//$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg';
//$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
//$pdf->render();
}
示例2: sendCampaign
public function sendCampaign()
{
// get abandoned cart :
$sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'";
$currency = Context::getContext()->currency->sign;
$defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
$abandoned_carts = Db::getInstance()->ExecuteS($sql);
// get all available campaigns
$sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1';
$allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns);
// loop on all abandoned carts
foreach ($abandoned_carts as $abncart) {
// loop on all available campaigns
foreach ($allCampaigns as $camp) {
$cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']);
if ($cartIsOnCampaign) {
$id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$customer = new Customer($abncart['id_customer']);
$cR = new CartRule($camp['id_voucher'], $id_lang);
$cart = new Cart($abncart['id_cart']);
$products = $cart->getProducts();
$campM = new Campaign($camp['id_campaign']);
if (!empty($products)) {
$cart_content = $campM->getCartContentHeader();
} else {
$cart_content = '';
}
foreach ($products as $prod) {
$p = new Product($prod['id_product'], true, $id_lang);
$price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false);
$total_no_tax = $prod['cart_quantity'] * $price_no_tax;
$images = Image::getImages((int) $id_lang, (int) $p->id);
$link = new Link();
$cart_content .= '<tr >
<td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td>
<td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td>
<td align="center" >' . Tools::displayprice($price_no_tax) . '</td>
<td align="center" >' . $prod['cart_quantity'] . '</td>
<td align="center" >' . Tools::displayprice($total_no_tax) . '</td>
</tr>';
}
$tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']);
$path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/';
// send email to customer :
Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id);
// Email to admin :
Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id);
// echo 'ID ' . $abncart['id_cart'];
}
}
}
}
示例3: Image
<?php
//complete code listing for controllers/guest/gallery.php
include_once "models/ImageModel.php";
$image = new Image("img");
$imageList = $image->getImages();
$galleryView = (include_once "views/gallery_view.php");
return $galleryView;
示例4: getPictures
function getPictures($prod_id, $link_rewrite)
{
$link = $this->context->link;
$cover = Image::getCover($prod_id);
$cover_picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $cover['id_image'], $this->image_type);
$pictures = array($cover_picture);
$images = Image::getImages($this->id_lang, $prod_id);
foreach ($images as $image) {
if ($image['id_image'] != $cover['id_image']) {
$picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $image['id_image'], $this->image_type);
$pictures[] = $picture;
}
}
return array_slice($pictures, 0, 10);
}
示例5: addProductImage
public static function addProductImage($id_product, $url)
{
${"GLOBALS"}["qrvdspdp"] = "url";
${"GLOBALS"}["foqvrjtcb"] = "url";
$cvtrsrijbi = "url";
$drrdziladf = "url";
${$cvtrsrijbi} = trim(${${"GLOBALS"}["qrvdspdp"]});
$woqkepntwhz = "id_product";
if (empty(${${"GLOBALS"}["ttqxfd"]})) {
return false;
}
${"GLOBALS"}["hocovvwcref"] = "product_has_images";
${$drrdziladf} = str_replace(" ", "%20", ${${"GLOBALS"}["foqvrjtcb"]});
${"GLOBALS"}["ghxtspka"] = "product_has_images";
${${"GLOBALS"}["ghxtspka"]} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${${"GLOBALS"}["szukprvdkbb"]});
${${"GLOBALS"}["bdufskktff"]} = new Image();
$image->id_product = (int) ${$woqkepntwhz};
$image->position = Image::getHighestPosition(${${"GLOBALS"}["szukprvdkbb"]}) + 1;
$image->cover = ${${"GLOBALS"}["hocovvwcref"]} ? false : true;
if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) {
$whmneeyreo = "url";
$image->associateTo(array(1));
return AgileHelper::copyImg(${${"GLOBALS"}["szukprvdkbb"]}, $image->id, ${$whmneeyreo}, "products", !Tools::getValue("regenerate"));
}
return false;
}
示例6: foreach
<title><![CDATA[<?php
echo Configuration::get('PS_SHOP_NAME');
?>
]]></title>
<url><?php
echo _PS_BASE_URL_ . __PS_BASE_URI__ . 'img/logo.jpg';
?>
</url>
<link><?php
echo _PS_BASE_URL_ . __PS_BASE_URI__;
?>
</link>
</image>
<?php
foreach ($products as $product) {
$image = Image::getImages(intval($cookie->id_lang), $product['id_product']);
echo "\t\t<item>\n";
echo "\t\t\t<title><![CDATA[" . $product['name'] . " - " . html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8') . " ]]></title>\n";
echo "\t\t\t<description>";
$cdata = true;
if (is_array($image) and sizeof($image)) {
echo "<![CDATA[<img src='" . _PS_BASE_URL_ . __PS_BASE_URI__ . "img/p/" . $image[0]['id_product'] . "-" . $image[0]['id_image'] . "-small.jpg' title='" . str_replace('&', '', $product['name']) . "' alt='thumb' />";
$cdata = false;
}
if ($cdata) {
echo "<![CDATA[";
}
echo $product['description_short'] . "]]></description>\n";
echo "\t\t\t<link><![CDATA[" . htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval($product['id_category_default']), $cookie->id_lang))) . $affiliate . "]]></link>\n";
echo "\t\t</item>\n";
}
示例7: attributeImportOne
protected function attributeImportOne($info, $default_language, &$groups, &$attributes, $regenerate, $shop_is_feature_active, $validateOnly = false)
{
AdminImportController::setDefaultValues($info);
if (!$shop_is_feature_active) {
$info['shop'] = 1;
} elseif (!isset($info['shop']) || empty($info['shop'])) {
$info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
}
// Get shops for each attributes
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
$id_shop_list = array();
if (is_array($info['shop']) && count($info['shop'])) {
foreach ($info['shop'] as $shop) {
if (!empty($shop) && !is_numeric($shop)) {
$id_shop_list[] = Shop::getIdByName($shop);
} elseif (!empty($shop)) {
$id_shop_list[] = $shop;
}
}
}
if (isset($info['id_product']) && $info['id_product']) {
$product = new Product((int) $info['id_product'], false, $default_language);
} elseif (Tools::getValue('match_ref') && isset($info['product_reference']) && $info['product_reference']) {
$datas = Db::getInstance()->getRow('
SELECT p.`id_product`
FROM `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p') . '
WHERE p.`reference` = "' . pSQL($info['product_reference']) . '"
', false);
if (isset($datas['id_product']) && $datas['id_product']) {
$product = new Product((int) $datas['id_product'], false, $default_language);
}
} else {
return;
}
$id_image = array();
if (isset($info['image_url']) && $info['image_url']) {
$info['image_url'] = explode($this->multiple_value_separator, $info['image_url']);
if (is_array($info['image_url']) && count($info['image_url'])) {
foreach ($info['image_url'] as $key => $url) {
$url = trim($url);
$product_has_images = (bool) Image::getImages($this->context->language->id, $product->id);
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = !$product_has_images ? true : false;
if (isset($info['image_alt'])) {
$alt = self::split($info['image_alt']);
if (isset($alt[$key]) && strlen($alt[$key]) > 0) {
$alt = self::createMultiLangField($alt[$key]);
$image->legend = $alt;
}
}
$field_error = $image->validateFields(UNFRIENDLY_ERROR, true);
$lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($field_error === true && $lang_field_error === true && !$validateOnly && $image->add()) {
$image->associateTo($id_shop_list);
// FIXME: 2s/image !
if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !$regenerate)) {
$this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Parameters.Notification'), $url);
$image->delete();
} else {
$id_image[] = (int) $image->id;
}
// until here
} else {
if (!$validateOnly) {
$this->warnings[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), isset($image->id_product) ? ' (' . $image->id_product . ')' : '');
}
if ($field_error !== true || $lang_field_error !== true) {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . mysql_error();
}
}
}
}
} elseif (isset($info['image_position']) && $info['image_position']) {
$info['image_position'] = explode($this->multiple_value_separator, $info['image_position']);
if (is_array($info['image_position']) && count($info['image_position'])) {
foreach ($info['image_position'] as $position) {
// choose images from product by position
$images = $product->getImages($default_language);
if ($images) {
foreach ($images as $row) {
if ($row['position'] == (int) $position) {
$id_image[] = (int) $row['id_image'];
break;
}
}
}
if (empty($id_image)) {
$this->warnings[] = sprintf($this->trans('No image was found for combination with id_product = %s and image position = %s.', array(), 'Admin.Parameters.Notification'), $product->id, (int) $position);
}
}
}
}
$id_attribute_group = 0;
// groups
$groups_attributes = array();
if (isset($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
//.........这里部分代码省略.........
示例8: array
}
if (!(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
$res = array();
foreach (Language::getIDs(false) as $id_lang) {
$res[$id_lang] = $link_rewrite;
}
$product->link_rewrite = $res;
}
if ($product->save()) {
$id_image = array();
//delete existing images if "delete_existing_images" is set to 1
$multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ',';
if (isset($prd['images']) && $prd['images']) {
$image_url = explode('/', $prd['images']);
$url = _PS_IMG_MGT_DIR_ . end($image_url);
$product_has_images = (bool) Image::getImages($id_lang, $product->id);
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = !$product_has_images ? true : false;
$field_error = $image->validateFields(UNFRIENDLY_ERROR, true);
$lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true);
$id_shop_list = array();
$errors = array();
$warnings = array();
$id_shop_list[] = $product->id_shop_default;
if ($image->add()) {
$image->associateTo($id_shop_list);
$image->getPathForCreation();
$image_final = $image->getPathForCreation() . '.jpg';
if (Tools::copy($url, $image_final)) {
示例9: attributeImport
public function attributeImport()
{
$default_language = Configuration::get('PS_LANG_DEFAULT');
$groups = array();
foreach (AttributeGroup::getAttributesGroups($default_language) as $group) {
$groups[$group['name']] = (int) $group['id_attribute_group'];
}
$attributes = array();
foreach (Attribute::getAttributes($default_language) as $attribute) {
$attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute'];
}
$this->receiveTab();
$handle = $this->openCsvFile();
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if (count($line) == 1 && empty($line[0])) {
continue;
}
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
}
$info = AdminImportController::getMaskedRow($line);
$info = array_map('trim', $info);
AdminImportController::setDefaultValues($info);
if (!Shop::isFeatureActive()) {
$info['shop'] = 1;
} elseif (!isset($info['shop']) || empty($info['shop'])) {
$info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
}
// Get shops for each attributes
$info['shop'] = explode($this->multiple_value_separator, $info['shop']);
$id_shop_list = array();
foreach ($info['shop'] as $shop) {
if (!is_numeric($shop)) {
$id_shop_list[] = Shop::getIdByName($shop);
} else {
$id_shop_list[] = $shop;
}
}
if (isset($info['id_product'])) {
$product = new Product((int) $info['id_product'], false, $default_language);
} else {
continue;
}
$id_image = null;
//delete existing images if "delete_existing_images" is set to 1
if (array_key_exists('delete_existing_images', $info) && $info['delete_existing_images'] && !isset($this->cache_image_deleted[(int) $product->id])) {
$product->deleteImages();
$this->cache_image_deleted[(int) $product->id] = true;
}
if (isset($info['image_url']) && $info['image_url']) {
$product_has_images = (bool) Image::getImages($this->context->language->id, $product->id);
$url = $info['image_url'];
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = !$product_has_images ? true : false;
$field_error = $image->validateFields(UNFRIENDLY_ERROR, true);
$lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true);
if ($field_error === true && $lang_field_error === true && $image->add()) {
$image->associateTo($id_shop_list);
if (!AdminImportController::copyImg($product->id, $image->id, $url)) {
$this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url);
$image->delete();
} else {
$id_image = array($image->id);
}
} else {
$this->warnings[] = sprintf(Tools::displayError('%s cannot be saved'), isset($image->id_product) ? ' (' . $image->id_product . ')' : '');
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . mysql_error();
}
} elseif (isset($info['image_position']) && $info['image_position']) {
$images = $product->getImages($default_language);
if ($images) {
foreach ($images as $row) {
if ($row['position'] == (int) $info['image_position']) {
$id_image = array($row['id_image']);
break;
}
}
}
if (!$id_image) {
$this->warnings[] = sprintf(Tools::displayError('No image was found for combination with id_product = %s and image position = %s.'), $product->id, (int) $info['image_position']);
}
}
$id_attribute_group = 0;
// groups
$groups_attributes = array();
if (isset($info['group'])) {
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) {
$tab_group = explode(':', $group);
$group = trim($tab_group[0]);
if (!isset($tab_group[1])) {
$type = 'select';
} else {
$type = trim($tab_group[1]);
}
// sets group
$groups_attributes[$key]['group'] = $group;
// if position is filled
//.........这里部分代码省略.........
示例10: addProductImage
public static function addProductImage($id_product, $url)
{
$seqtjskmdfi = "url";
${${"GLOBALS"}["uhoixbgwu"]} = trim(${$seqtjskmdfi});
if (empty(${${"GLOBALS"}["uhoixbgwu"]})) {
return false;
}
$lnmoeujjg = "id_product";
$uplftstbult = "image";
${"GLOBALS"}["mrbbkxa"] = "url";
${${"GLOBALS"}["mrbbkxa"]} = str_replace(" ", "%20", ${${"GLOBALS"}["uhoixbgwu"]});
${${"GLOBALS"}["btjrhesgdily"]} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${$lnmoeujjg});
${$uplftstbult} = new Image();
$image->id_product = (int) ${${"GLOBALS"}["hmkfzguifam"]};
$image->position = Image::getHighestPosition(${${"GLOBALS"}["hmkfzguifam"]}) + 1;
$image->cover = ${${"GLOBALS"}["btjrhesgdily"]} ? false : true;
if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) {
${"GLOBALS"}["cubrmeyruje"] = "id_product";
$image->associateTo(array(1));
return AgileHelper::copyImg(${${"GLOBALS"}["cubrmeyruje"]}, $image->id, ${${"GLOBALS"}["uhoixbgwu"]}, "products", !Tools::getValue("regenerate"));
}
return false;
}
示例11: hookHeader
public function hookHeader($params)
{
$shop_id = $this->getShopId();
$buttons_code = $this->client->getButtonsCode();
if (Configuration::get('ADDSHOPPERS_OPENGRAPH') == '1') {
$this->context->smarty->assign('buttons_opengraph', $buttons_code['buttons']['open-graph']);
}
if (Configuration::get('ADDSHOPPERS_BUTTONS') == '1') {
$this->context->smarty->assign('buttons_social', $buttons_code['buttons']['button2']);
}
$id_lang = (int) Tools::getValue('id_lang', (int) Configuration::get('PS_LANG_DEFAULT'));
$this->context->smarty->assign(array('shop_id' => Tools::safeOutput($shop_id), 'default_account' => $shop_id == $this->client->getDefaultShopId(), 'social' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_BUTTONS')), 'opengraph' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_OPENGRAPH')), 'actual_url' => Tools::safeOutput($this->_getCurrentUrl()), 'absolute_base_url' => Tools::safeOutput($this->_getAbsoluteBaseUrl()), 'id_lang' => (int) $id_lang));
if (Tools::isSubmit('id_product')) {
$product = new Product((int) Tools::getValue('id_product'));
if (Validate::isLoadedObject($product)) {
$currency = new Currency((int) $this->context->cookie->id_currency);
$this->context->smarty->assign(array('id_product' => (int) $product->id, 'stock' => isset($product->available_now) ? Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_IN_STOCK) : Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_OUT_OF_STOCK), 'price' => Tools::safeOutput($currency->sign) . number_format((double) $product->getPrice(), 2), 'product_name' => Tools::safeOutput($product->name[$id_lang]), 'product_description' => Tools::safeOutput($product->description[$id_lang]), 'is_product_page' => true));
$quantity = (int) StockAvailable::getQuantityAvailableByProduct((int) $product->id);
if ($quantity > 0) {
$this->context->smarty->assign('instock', (int) $quantity);
}
$images = Image::getImages((int) $id_lang, (int) $product->id);
if (is_array($images) && isset($images[0])) {
$this->context->smarty->assign('id_image', (int) $images[0]['id_image']);
}
} else {
$this->context->smarty->assign('is_product_page', false);
}
} else {
$this->context->smarty->assign('is_product_page', false);
}
return $this->display(__FILE__, 'header.tpl');
}
示例12: content_55576e4d495d27_71185436
function content_55576e4d495d27_71185436($_smarty_tpl)
{
?>
<div <?php
if (isset($_smarty_tpl->tpl_vars['id']->value) && $_smarty_tpl->tpl_vars['id']->value) {
?>
id="<?php
echo $_smarty_tpl->tpl_vars['id']->value;
?>
"<?php
}
?>
class="carousel-list clearfix<?php
if (isset($_smarty_tpl->tpl_vars['c_class']->value) && $_smarty_tpl->tpl_vars['c_class']->value) {
?>
<?php
echo $_smarty_tpl->tpl_vars['c_class']->value;
}
?>
owl_wrap">
<?php
if (isset($_smarty_tpl->tpl_vars['products']->value) && $_smarty_tpl->tpl_vars['products']->value && count($_smarty_tpl->tpl_vars['products']->value) > 0) {
?>
<!-- Products list -->
<?php
$_smarty_tpl->tpl_vars['product'] = new Smarty_Variable();
$_smarty_tpl->tpl_vars['product']->_loop = false;
$_from = $_smarty_tpl->tpl_vars['products']->value;
if (!is_array($_from) && !is_object($_from)) {
settype($_from, 'array');
}
foreach ($_from as $_smarty_tpl->tpl_vars['product']->key => $_smarty_tpl->tpl_vars['product']->value) {
$_smarty_tpl->tpl_vars['product']->_loop = true;
?>
<ul class="product_list grid">
<li class="ajax_block_product item">
<?php
$_smarty_tpl->tpl_vars['imginfo'] = new Smarty_variable(Image::getImages(Language::getIdByIso($_smarty_tpl->tpl_vars['lang_iso']->value), $_smarty_tpl->tpl_vars['product']->value['id_product']), null, 0);
?>
<?php
$_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable('', null, 0);
?>
<?php
$_smarty_tpl->tpl_vars['imgitem'] = new Smarty_Variable();
$_smarty_tpl->tpl_vars['imgitem']->_loop = false;
$_from = $_smarty_tpl->tpl_vars['imginfo']->value;
if (!is_array($_from) && !is_object($_from)) {
settype($_from, 'array');
}
foreach ($_from as $_smarty_tpl->tpl_vars['imgitem']->key => $_smarty_tpl->tpl_vars['imgitem']->value) {
$_smarty_tpl->tpl_vars['imgitem']->_loop = true;
?>
<?php
if (!$_smarty_tpl->tpl_vars['imgitem']->value['cover']) {
?>
<?php
$_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['imgitem']->value['id_product'] . "-" . (string) $_smarty_tpl->tpl_vars['imgitem']->value['id_image'], null, 0);
?>
<?php
break 1;
?>
<?php
}
?>
<?php
}
?>
<div class="product-container" itemscope itemtype="http://schema.org/Product">
<div class="left-block">
<div class="product-image-container">
<a class="product_img_link" href="<?php
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true);
?>
" title="<?php
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true);
?>
" itemprop="url">
<img class="replace-2x img-responsive" src="<?php
echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value['link_rewrite'], $_smarty_tpl->tpl_vars['product']->value['id_image'], 'home_default'), ENT_QUOTES, 'UTF-8', true);
?>
" alt="<?php
if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) {
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true);
} else {
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true);
}
?>
" title="<?php
if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) {
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true);
} else {
echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true);
}
?>
" <?php
if (isset($_smarty_tpl->tpl_vars['homeSize']->value)) {
?>
width="<?php
//.........这里部分代码省略.........
开发者ID:blaz1988,项目名称:presta,代码行数:101,代码来源:3efc326bb8d2592d0adac63f55e8a032b9619531.file.product-list-home.tpl.cache.php
示例13: addProductImage
public static function addProductImage($id_product, $url)
{
$rhueeqpyqid = "url";
$hrqreqrws = "product_has_images";
$gdvfsxvvwqw = "id_product";
$muucuokjnr = "url";
${$muucuokjnr} = trim(${$rhueeqpyqid});
${"GLOBALS"}["spvdeam"] = "url";
if (empty(${${"GLOBALS"}["csdyhfby"]})) {
return false;
}
${${"GLOBALS"}["csdyhfby"]} = str_replace(" ", "%20", ${${"GLOBALS"}["spvdeam"]});
${"GLOBALS"}["mmicugw"] = "image";
${$hrqreqrws} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${$gdvfsxvvwqw});
${${"GLOBALS"}["mmicugw"]} = new Image();
$image->id_product = (int) ${${"GLOBALS"}["ktxxdlcenjrd"]};
$image->position = Image::getHighestPosition(${${"GLOBALS"}["ktxxdlcenjrd"]}) + 1;
${"GLOBALS"}["mincqrvbtcit"] = "product_has_images";
$image->cover = ${${"GLOBALS"}["mincqrvbtcit"]} ? false : true;
if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) {
$image->associateTo(array(1));
${"GLOBALS"}["vgrilvvuoi"] = "id_product";
${"GLOBALS"}["flxzymmafk"] = "url";
return AgileHelper::copyImg(${${"GLOBALS"}["vgrilvvuoi"]}, $image->id, ${${"GLOBALS"}["flxzymmafk"]}, "products", !Tools::getValue("regenerate"));
}
return false;
}
示例14: displayDuplicateLink
/**
* Display duplicate action link
*/
public function displayDuplicateLink($token = null, $id, $name = null)
{
$tpl = $this->createTemplate('list_action_duplicate.tpl');
if (!array_key_exists('Bad SQL query', self::$cache_lang)) {
self::$cache_lang['Duplicate'] = $this->l('Duplicate', 'Helper');
}
if (!array_key_exists('Copy images too?', self::$cache_lang)) {
self::$cache_lang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "Yes". If not, click "No".', 'Helper');
}
$duplicate = $this->currentIndex . '&' . $this->identifier . '=' . $id . '&duplicate' . $this->table;
$confirm = self::$cache_lang['Copy images too?'];
if ($this->table == 'product' && !(bool) Image::getImages($this->context->language->id, (int) $id)) {
$confirm = '';
}
$tpl->assign(array('href' => $this->currentIndex . '&' . $this->identifier . '=' . $id . '&view' . $this->table . '&token=' . ($token != null ? $token : $this->token), 'action' => self::$cache_lang['Duplicate'], 'confirm' => $confirm, 'location_ok' => $duplicate . '&token=' . ($token != null ? $token : $this->token), 'location_ko' => $duplicate . '&noimage=1&token=' . ($token ? $token : $this->token)));
return $tpl->fetch();
}
示例15: productImport
//.........这里部分代码省略.........
$product->quantity = 0;
}
// If id product AND id product already in base, trying to update
if ($product->id and Product::existsInDatabase((int) $product->id)) {
$datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product->id);
$product->date_add = pSQL($datas['date_add']);
$res = $product->update();
}
// If no id_product or update failed
if (!$res) {
$res = $product->add();
}
}
// If both failed, mysql error
if (!$res) {
$this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
} else {
// SpecificPrice (only the basic reduction feature is supported by the import)
if (isset($info['reduction_price']) or isset($info['reduction_percent'])) {
$specificPrice = new SpecificPrice();
$specificPrice->id_product = (int) $product->id;
$specificPrice->id_shop = (int) Shop::getCurrentShop();
$specificPrice->id_currency = 0;
$specificPrice->id_country = 0;
$specificPrice->id_group = 0;
$specificPrice->price = 0.0;
$specificPrice->from_quantity = 1;
$specificPrice->reduction = (isset($info['reduction_price']) and $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100;
$specificPrice->reduction_type = (isset($info['reduction_price']) and $info['reduction_price']) ? 'amount' : 'percentage';
$specificPrice->from = (isset($info['reduction_from']) and Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
$specificPrice->to = (isset($info['reduction_to']) and Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
if (!$specificPrice->add()) {
$this->_addProductWarning($info['name'], $product->id, $this->l('Discount is invalid'));
}
}
if (isset($product->tags) and !empty($product->tags)) {
// Delete tags for this id product, for no duplicating error
Tag::deleteTagsForProduct($product->id);
$tag = new Tag();
if (!is_array($product->tags)) {
$product->tags = self::createMultiLangField($product->tags);
foreach ($product->tags as $key => $tags) {
$isTagAdded = $tag->addTags($key, $product->id, $tags);
if (!$isTagAdded) {
$this->_addProductWarning($info['name'], $product->id, $this->l('Tags list') . ' ' . $this->l('is invalid'));
break;
}
}
} else {
foreach ($product->tags as $key => $tags) {
$str = '';
foreach ($tags as $one_tag) {
$str .= $one_tag . ',';
}
$str = rtrim($str, ',');
$isTagAdded = $tag->addTags($key, $product->id, $str);
if (!$isTagAdded) {
$this->_addProductWarning($info['name'], $product->id, 'Invalid tag(s) (' . $str . ')');
break;
}
}
}
}
if (isset($product->image) and is_array($product->image) and sizeof($product->image)) {
$productHasImages = (bool) Image::getImages((int) $cookie->id_lang, (int) $product->id);
foreach ($product->image as $key => $url) {
if (!empty($url)) {
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$image->cover = (!$key and !$productHasImages) ? true : false;
$image->legend = self::createMultiLangField($product->name[$defaultLanguageId]);
if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $image->add()) {
if (!self::copyImg($product->id, $image->id, $url)) {
$this->_warnings[] = Tools::displayError('Error copying image: ') . $url;
}
} else {
$this->_warnings[] = $image->legend[$defaultLanguageId] . (isset($image->id_product) ? ' (' . $image->id_product . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
}
if (isset($product->id_category)) {
$product->updateCategories(array_map('intval', $product->id_category));
}
$features = get_object_vars($product);
foreach ($features as $feature => $value) {
if (!strncmp($feature, '#F_', 3) and Tools::strlen($product->{$feature})) {
$feature_name = str_replace('#F_', '', $feature);
$id_feature = Feature::addFeatureImport($feature_name);
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $product->{$feature});
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
}
}
}
}
$this->closeCsvFile($handle);
}