예제 #1
0
 /**
  * Get all categories from database arranged by parents
  * 
  * @param mixed $categories
  * @param mixed $parent
  * @param mixed $indent
  * @param mixed $include_subs
  * @param mixed $exclude
  * @param mixed $order
  */
 public function categos_list(&$categories, $parent = 0, $indent = 0, $include_subs = true, $exclude = 0, $order = "id_cat DESC")
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("shop_categories") . " WHERE parent='{$parent}' ORDER BY {$order}";
     $result = $db->query($sql);
     while ($row = $db->fetchArray($result)) {
         if ($row['id_cat'] == $exclude) {
             continue;
         }
         $row['indent'] = $indent;
         $cat = new ShopCategory();
         $cat->assignVars($row);
         $row['link'] = $cat->permalink();
         $categories[] = $row;
         if ($include_subs) {
             ShopFunctions::categos_list($categories, $row['id_cat'], $indent + 1, $include_subs, $exclude);
         }
     }
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
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 &#8216;%s&#8217; 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}'));
$xoopsTpl->assign('pagenav', $nav->render(false));
$result = $db->query("SELECT {$tbl3}.* FROM {$tbl2}, {$tbl3} WHERE {$tbl2}.cat='{$category}' \n        AND {$tbl3}.id_product={$tbl2}.product ORDER BY " . ($xoopsModuleConfig['sort'] ? " {$tbl3}.`name`" : " {$tbl3}.id_product DESC") . " LIMIT {$start},{$limit}");
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']);
$xoopsTpl->assign('lang_instock', __('In stock', 'shop'));
$xoopsTpl->assign('lang_outstock', __('Out of stock', 'shop'));
$xoopsTpl->assign('lang_selcat', __('Select category...', 'shop'));
$xoopsTpl->assign('xoops_pagetitle', $catego->getVar('name') . ' - ' . $xoopsModuleConfig['modtitle']);
RMTemplate::get()->add_style('main.css', 'shop');
include 'footer.php';