Ejemplo n.º 1
0
function shop_bk_products_show($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/shop/class/shopproduct.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/shop/class/shopfunctions.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $limit = $options[2] > 0 ? $options[2] : 5;
    $ord = $options[0] <= 0 ? ' `created` DESC' : 'RAND()';
    $mc = RMUtilities::module_config('shop', 'format');
    if ($options[1] != '') {
        $tp = $db->prefix("shop_products");
        $tc = $db->prefix("shop_categories");
        $tcp = $db->prefix("shop_catprods");
        $sql = "SELECT p.* FROM {$tp} as p, {$tcp} as r WHERE r.cat={$options['1']} AND p.id_product=r.product GROUP BY r.product";
    } else {
        $sql = "SELECT * FROM " . $db->prefix("shop_products");
    }
    $sql .= " ORDER BY {$ord} LIMIT 0,{$limit}";
    $result = $db->query($sql);
    $products = array();
    while ($row = $db->fetchArray($result)) {
        $prod = new ShopProduct();
        $prod->assignVars($row);
        $products[] = array('id' => $prod->id(), 'name' => $prod->getVar('name'), 'link' => $prod->permalink(), 'price' => sprintf($mc, number_format($prod->getVar('price'), 2)), 'type' => $prod->getVar('type') ? __('Digital', 'shop') : 'Product', 'stock' => $prod->getVar('available'), 'image' => $prod->getVar('image'));
    }
    $block['products'] = $products;
    unset($prod, $products, $sql, $result, $row, $ord, $limit, $db);
    $block['show_image'] = $options[3];
    $block['width'] = $options[4];
    $block['height'] = $options[5];
    $block['display'] = $options[6];
    $block['name'] = in_array("name", $options);
    $block['price'] = in_array("price", $options);
    $block['type'] = in_array("type", $options);
    $block['stock'] = in_array("stock", $options);
    $block['lang_stock'] = __('In stock', 'shop');
    $block['lang_nostock'] = __('Out of stock', 'shop');
    // Add styles
    RMTemplate::get()->add_style('blocks.css', 'shop');
    return $block;
}
Ejemplo n.º 2
0
<?php

// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$tf = new RMTimeFormatter(0, '%d%/%M%/%Y%');
$var = isset($var) ? $var : 'products';
while ($row = $db->fetchArray($result)) {
    $product = new ShopProduct();
    $product->assignVars($row);
    $sf = new ShopFunctions();
    $xoopsTpl->append($var, array('id' => $product->id(), 'name' => $product->getVar('name'), 'nameid' => $product->getVar('nameid'), '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' => SHOP_UPURL . '/ths/' . $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()));
}
Ejemplo n.º 3
0
// 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');
// Now minishop will use lightbox plugin for Common Utilities
if (RMFunctions::plugin_installed('lightbox')) {
    RMLightbox::get()->add_element('.prod_thumbs a');
    RMLightbox::get()->render();
Ejemplo n.º 4
0
// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
define('RMCLOCATION', 'dashboard');
include 'header.php';
RMTemplate::get()->add_head('<script type="text/javascript">var xurl="' . XOOPS_URL . '";</script>');
RMTemplate::get()->add_local_script('dashmain.js', 'shop');
RMTemplate::get()->add_style('admin.css', 'shop');
RMTemplate::get()->add_style('dashboard.css', 'shop');
$db = XoopsDatabaseFactory::getDatabaseConnection();
// Products count
$sql = "SELECT COUNT(*) FROM " . $db->prefix("shop_products");
list($prods_count) = $db->fetchRow($db->query($sql));
$sql = "SELECT COUNT(*) FROM " . $db->prefix("shop_categories");
list($cats_count) = $db->fetchRow($db->query($sql));
$sql = "SELECT * FROM " . $db->prefix("shop_products") . " ORDER BY id_product DESC LIMIT 0, 5";
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $prod = new ShopProduct();
    $prod->assignVars($row);
    $products[] = array('id' => $prod->id(), 'name' => $prod->getVar('name'), 'link' => $prod->permalink(), 'image' => $prod->getVar('image'));
}
ShopFunctions::include_required_files();
xoops_cp_header();
include RMTemplate::get()->get_template('admin/shop_dashboard.php', 'module', 'shop');
xoops_cp_footer();
Ejemplo n.º 5
0
// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$product = new ShopProduct($contact);
if ($product->isNew()) {
    ShopFunctions::error404();
}
$action = rmc_server_var($_POST, 'action', '');
if ($action == 'send') {
    $url = ShopFunctions::get_url();
    $url .= $xoopsModuleConfig['urlmode'] ? 'contact/' . $product->getVar('nameid') . '/' : '?contact=' . $product->id();
    $name = rmc_server_var($_POST, 'name', '');
    $email = rmc_server_var($_POST, 'email', '');
    $message = rmc_server_var($_POST, 'message', '');
    if ($name == '' || $message == '' || $email == '') {
        redirect_header($url, 1, __('Please fill al required data!', 'shop'));
        die;
    }
    // Recaptcha check
    if (!RMEvents::get()->run_event('rmcommon.captcha.check', true)) {
        redirect_header($url, 1, __('Please check the security words and write it correctly!', 'shop'));
        die;
    }
    $xoopsMailer =& getMailer();
    $xoopsMailer->useMail();
    $xoopsMailer->setBody(sprintf(__('A user has requested more information about the product %s. User message below.', 'shop'), $product->getVar('name')) . "\n---------------\n" . $message . "\n--------------\n" . __('Message sent with MiniShop', 'shop') . "\n" . ShopFunctions::get_url());
Ejemplo n.º 6
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;
    }
}