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; }
<?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())); }
// $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());
// $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();
/** * @desc Almacena las imágenes en la base de datos **/ function shop_save_image($edit = 0) { global $xoopsModuleConfig, $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } $ruta = "action=images&page={$page}&bname={$bname}&id={$id}"; //Verificamos que el trabajo sea válido if ($id <= 0) { redirectMsg('products.php', __('You must specify a product ID!', 'shop'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('products.php?' . $ruta, __('Session token expired!', 'shop'), 1); die; } //Verificamos que el trabajo exista $product = new ShopProduct($id); if ($product->isNew()) { redirectMsg('products.php', __('Specified product does not exists!', 'shop'), 1); die; } if ($edit) { //Verificamos que la imagen sea válida if ($idimg <= 0) { redirectMsg('products.php?' . $ruta, __('You must specify an image ID!', 'shop'), 1); die; } //Verificamos que la imagen exista $img = new ShopImage($idimg); if ($img->isNew()) { redirectMsg('products.php?' . $ruta, __('Specified image does not exists!', 'shop'), 1); die; } } else { $img = new ShopImage(); } $img->setVar('title', $title); $img->setVar('description', $description); $img->setVar('product', $product->id()); //Imagen include_once RMCPATH . '/class/uploader.php'; $folder = XOOPS_UPLOAD_PATH . '/minishop'; $folderths = XOOPS_UPLOAD_PATH . '/minishop/ths'; if ($edit) { $image = $img->getVar('file'); $filename = $img->getVar('file'); } else { $filename = ''; } //Obtenemos el tamaño de la imagen $thSize = explode("|", $xoopsModuleConfig['thssize']); $imgSize = explode("|", $xoopsModuleConfig['imgsize']); $up = new RMFileUploader($folder, $xoopsModuleConfig['maxsize'] * 1024, array('jpg', 'png', 'gif')); if ($up->fetchMedia('file')) { if (!$up->upload()) { redirectMsg('products.php?action=' . ($edit ? 'edit' : 'new') . '&' . $ruta, $up->getErrors(), 1); die; } if ($edit && $img->getVar('file') != '') { @unlink(XOOPS_UPLOAD_PATH . '/minishop/' . $img->getVar('file')); @unlink(XOOPS_UPLOAD_PATH . '/minishop/ths/' . $img->getVar('file')); } $filename = $up->getSavedFileName(); $fullpath = $up->getSavedDestination(); // Redimensionamos la imagen $redim = new RMImageResizer($fullpath, $fullpath); if ($xoopsModuleConfig['imgredim']) { $redim->resizeAndCrop($imgSize[0], $imgSize[1]); } else { $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]); } $redim->setTargetFile($folderths . "/{$filename}"); if ($xoopsModuleConfig['thsredim']) { $redim->resizeAndCrop($thSize[0], $thSize[1]); } else { $redim->resizeWidthOrHeight($thSize[0], $thSize[1]); } } $img->setVar('file', $filename); RMEvents::get()->run_event('shop.save.image', $img); if (!$img->save()) { redirectMsg('products.php?action=images&' . $ruta, __('Errors ocurred while trying to save the image', 'shop') . '<br />' . $img->errors(), 1); die; } else { redirectMsg('products.php?' . $ruta, __('Database updated successfully!', 'shop'), 0); die; } }