Exemplo n.º 1
0
<?php

// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$product = new ShopProduct($id);
if ($product->isNew()) {
    ShopFunctions::error404();
}
$xoopsOption['template_main'] = 'shop_product.html';
include 'header.php';
$tf = new RMTimeFormatter(0, '%d%/%T%/%Y%');
$sf = new ShopFunctions();
// Product data
$xoopsTpl->assign('product', array('name' => $product->getVar('name'), 'description' => $product->getVar('description'), 'price' => $product->getVar('price') > 0 ? sprintf(__('Price: <strong>%s</strong>', 'shop'), sprintf($xoopsModuleConfig['format'], number_format($product->getVar('price'), 2))) : '', 'buy' => $sf->get_buy_link($product), 'type' => $product->getVar('type'), 'stock' => $product->getVar('available'), 'image' => $product->getVar('image'), 'created' => sprintf(__('Since: <strong>%s</strong>', 'shop'), $tf->format($product->getVar('created'))), 'updated' => $product->getVar('modified') > 0 ? sprintf(__("Updated: <strong>%s</strong>", 'shop'), $tf->format($product->getVar('modified'))) : '', 'link' => $product->permalink(), 'metas' => $product->get_meta(), 'images' => $product->get_images()));
$product->setVar('hits', $product->getVar('hits') + 1);
$product->save();
$options = array('<a href="' . ShopFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'contact/' . $product->getVar('nameid') . '/' : '?contact=' . $product->id()) . '">' . __('Request Information', 'shop') . '</a>');
$options = RMEvents::get()->run_event('shop.product.options', $options);
$xoopsTpl->assign('options', $options);
$xoopsTpl->assign('product_details', 1);
$xoopsTpl->assign('xoops_pagetitle', $product->getVar('name') . ' &raquo; ' . $xoopsModuleConfig['modtitle']);
$xoopsTpl->assign('lang_instock', __('In stock', 'shop'));
$xoopsTpl->assign('lang_outstock', __('Out of stock', 'shop'));
$xoopsTpl->assign('lang_buy', __('Buy Now!', 'shop'));
RMTemplate::get()->add_style('main.css', 'shop');
Exemplo n.º 2
0
function shop_generate_thumbs()
{
    global $xoopsSecurity, $xoopsModule, $xoopsModuleConfig;
    $ids = rmc_server_var($_POST, 'ids', 0);
    $page = rmc_server_var($_POST, 'page', 1);
    $bname = rmc_server_var($_POST, 'bname', '');
    $ruta = "page={$page}&bname={$bname}";
    //Verificamos que nos hayan proporcionado un trabajo para eliminar
    if (!is_array($ids)) {
        redirectMsg('products.php?' . $ruta, __('You must select one product at least!', 'shop'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('products.php?' . $ruta, __('Session token expired!', 'shop'), 1);
        die;
    }
    //Obtenemos el tamaño de la imagen
    $thSize = explode("|", $xoopsModuleConfig['thssize']);
    $imgSize = explode("|", $xoopsModuleConfig['imgsize']);
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si el trabajo es válido
        if ($k <= 0) {
            $errors .= sprintf(__('Product ID "%s" is not valid!', 'shop'), $k);
            continue;
        }
        //Verificamos si el trabajo existe
        $product = new ShopProduct($k);
        if ($product->isNew()) {
            $errors .= sprintf(__('Product with ID "%s" does not exists!', 'shop'), $k);
            continue;
        }
        // Redimensionamos la imagen
        $path = XOOPS_UPLOAD_PATH . '/minishop/';
        $redim = new RMImageResizer($path . $product->getVar('image'), $path . 'ths/' . $product->getVar('image'));
        if ($xoopsModuleConfig['thsredim']) {
            $redim->resizeAndCrop($thSize[0], $thSize[1]);
        } else {
            $redim->resizeWidthOrHeight($thSize[0], $thSize[1]);
        }
    }
    if ($errors != '') {
        redirectMsg('products.php?' . $ruta, __('Errors ocurred while trying to regenerate thumbnails', 'shop') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('products.php?' . $ruta, __('Thumbnails regenerated successfully!', 'shop'), 0);
        die;
    }
}