/** * Obtiene el enlace a la categor?a */ public function permalink() { $mc = RMUtilities::module_config('shop'); $link = ShopFunctions::get_url(); $link .= $mc['urlmode'] == 0 ? '?cat=' . $this->id() : 'category/' . $this->path(); return $link; }
// 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') . ' » ' . $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(); } include 'footer.php';
<?php // $Id$ // -------------------------------------------------------------- // MiniShop 3 // Module for catalogs // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- require_once XOOPS_ROOT_PATH . '/header.php'; define('SHOP_PATH', XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname()); define('SHOP_URL', XOOPS_URL . '/modules/' . $xoopsModule->dirname()); define('SHOP_UPPATH', XOOPS_UPLOAD_PATH . '/minishop'); define('SHOP_UPURL', XOOPS_UPLOAD_URL . '/minishop'); $xoopsTpl->assign('shopConfig', $xoopsModuleConfig); $xoopsTpl->assign('shop_url', ShopFunctions::get_url());
// Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- $xoopsOption['template_main'] = 'shop_index.html'; include 'header.php'; $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT COUNT(*) FROM " . $db->prefix("shop_products"); list($num) = $db->fetchRow($db->query($sql)); $limit = $xoopsModuleConfig['numxpage']; $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $p = $page > 0 ? $page - 1 : $page; $start = $num <= 0 ? 0 : $p * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url(ShopFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'page/{PAGE_NUM}/' : '?page={PAGE_NUM}')); $xoopsTpl->assign('pagenav', $nav->render(false)); $result = $db->query("SELECT * FROM " . $db->prefix("shop_products") . " ORDER BY id_product DESC LIMIT {$start}," . $xoopsModuleConfig['recents']); $var = 'recents'; include 'include/product-data.php'; $result = $db->query("SELECT * FROM " . $db->prefix("shop_products") . " ORDER BY hits DESC LIMIT {$start}," . $xoopsModuleConfig['populars']); $var = 'popular'; include 'include/product-data.php'; $result = $db->query("SELECT * FROM " . $db->prefix("shop_products") . " ORDER BY RAND() LIMIT {$start}," . $xoopsModuleConfig['random']); $var = 'random'; include 'include/product-data.php'; $categories = array(); ShopFunctions::categos_list($categories); array_walk($categories, 'shop_dashed'); $xoopsTpl->assign('categories_list', $categories); $xoopsTpl->assign('columns', $xoopsModuleConfig['columns']);
/** * Devuelve los nombres de las categorías a las que pertenece * el post actual * @param bool $asList Detemina si se muestra en forma de lista o de array * @param string $delimiter Delimitador para la lista * @param bool Get names with links. Only works when $asList equal true * @param string Section for link. It can be front or admin. Only works when $asList equal true * @return string or array */ public function get_categories_names($asList = true, $delimiter = ',', $links = true, $section = 'front') { if (empty($this->lcats)) { $this->get_categos('data'); } $rtn = $asList ? '' : array(); $url = ShopFunctions::get_url(); foreach ($this->lcats as $cat) { if ($asList) { if ($links) { $category = new ShopCategory(); $category->assignVars($cat); $rtn .= $rtn == '' ? '' : "{$delimiter}"; $rtn .= '<a href="' . ($section == 'front' ? $category->permalink() : 'products.php?cat=' . $cat['id_cat']) . '">' . $cat['name'] . '</a>'; } else { $rtn .= $rtn == '' ? $cat['name'] : "{$delimiter} {$cat['name']}"; } } else { $rtn[] = $row['nombre']; } } return $rtn; }
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()); $xoopsMailer->setToEmails($xoopsModuleConfig['email']); $xoopsMailer->setFromEmail($email); $xoopsMailer->setFromName($name); $xoopsMailer->setSubject(sprintf(__('Information request about product %s', 'shop'), $product->getVar('name'))); if (!$xoopsMailer->send(true)) { redirect_header($url, 1, __('Message could not be delivered. Please try again.', 'shop')); die; } redirect_header(ShopFunctions::get_url(), 1, __('Your message has been sent successfully!', 'shop')); } else { $xoopsOption['template_main'] = 'shop_contact.html'; include 'header.php'; $tf = new RMTimeFormatter(0, '%d%/%M%/%Y%'); // Product data $xoopsTpl->assign('product', array('name' => $product->getVar('name'), 'description' => $product->getVar('description'), 'price' => sprintf(__('Price: <strong>%s</strong>', 'shop'), sprintf($xoopsModuleConfig['format'], number_format($product->getVar('price'), 2))), '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())); $categories = array(); ShopFunctions::categos_list($categories); array_walk($categories, 'shop_dashed'); $xoopsTpl->assign('categories_list', $categories); $xoopsTpl->assign('lang_selcat', __('Select category...', 'shop')); $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Requesting information about %s', 'shop'), $product->getVar('name')) . ' » ' . $xoopsModuleConfig['modtitle']); $xoopsTpl->assign('lang_requesting_info', sprintf(__('Request Information for %s', 'shop'), $product->getVar('name'))); $xoopsTpl->assign('lang_yname', __('Your Name:', 'shop')); $xoopsTpl->assign('lang_ymail', __('Your Email:', 'shop'));
$path = explode("/", $category); foreach ($path as $k) { if ($k == '') { continue; } $sql = "SELECT id_cat FROM {$tbl1} WHERE shortname='{$k}' AND parent='{$idp}'"; $result = $db->query($sql); if ($db->getRowsNum($result) > 0) { list($idp) = $db->fetchRow($result); } } $category = $idp; } $catego = new ShopCategory($category); if ($catego->isNew()) { redirect_header(ShopFunctions::get_url(), 1, __('Specified category could not be found', 'shop')); die; } // Category data $xoopsTpl->assign('category', array('id' => $catego->id(), 'name' => $catego->getVar('name'))); $xoopsTpl->assign('lang_prodsincat', sprintf(__('Products in ‘%s’ Category', 'shop'), $catego->getVar('name'))); $limit = $xoopsModuleConfig['numxpage']; list($num) = $db->fetchRow($db->query("SELECT COUNT({$tbl2}.product) FROM {$tbl2}, {$tbl3} WHERE {$tbl2}.cat='{$category}' \n AND {$tbl3}.id_product={$tbl2}.product")); $page = isset($page) && $page > 0 ? $page : 1; $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $p = $page > 0 ? $page - 1 : $page; $start = $num <= 0 ? 0 : $p * $limit; $xoopsTpl->assign('page', $page); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url($catego->permalink() . ($xoopsModuleConfig['urlmode'] ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}'));