Beispiel #1
0
/**
 * Muestra una lista de las categorías existentes
 */
function shop_show_categos()
{
    global $xoopsModule, $xoopsSecurity;
    $row = array();
    ShopFunctions::categos_list($row);
    $categories = array();
    foreach ($row as $k) {
        $catego = new ShopCategory();
        $catego->assignVars($k);
        $catego->loadProducts();
        $categories[] = array('id_cat' => $catego->id(), 'description' => $catego->getVar('description', 'n'), 'products' => $catego->getVar('products', 'n'), 'name' => $catego->getVar('name', 'n'), 'indent' => $k['indent'], 'shortname' => $catego->getVar('shortname', 'n'));
    }
    // Categories pagination
    // Paginamos
    $limit = 15;
    if (count($categories) > $limit) {
        $page = rmc_server_var($_GET, 'page', 1);
        $page = $page < 1 ? 1 : $page;
        $limit_c = $page * ($limit - 1);
        $limit_c = $limit_c > count($categories) - 1 ? count($categories) - 1 : $limit_c;
        $tpages = ceil(count($categories) / 3);
        if ($page > $tpages) {
            $page = $tpages;
        }
        $nav = new RMPageNav(count($categories), $limit, $page, 5);
        $nav->target_url('?page={PAGE_NUM}');
        $i = ($page - 1) * $limit;
        while ($i <= $limit_c) {
            $pcategories[] = $categories[$i];
            $i++;
        }
        $categories = $pcategories;
    }
    ShopFunctions::include_required_files();
    RMTemplate::get()->add_head('<script type="text/javascript">
            function cat_del_confirm(cat, id){
      
              var string = "' . __('Do you really want to delete "%s"', 'shop') . '";
                     string = string.replace("%s", cat);
                     var ret = confirm(string);
                     
                     if (ret){
                         $("#tblCats input[type=checkbox]").removeAttr("checked");
                         $("#cat-"+id).attr("checked","checked");
                         $("#cat-op").val("delete");
                         $("#tblCats").submit();
                    }
              
          }
      </script>');
    RMTemplate::get()->set_help('http://redmexico.com.mx/docs/minishop/');
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . __('Categories', 'shop'));
    xoops_cp_header();
    $desc = '';
    $posts = '';
    $parent = '';
    $selcat = '';
    $new = '';
    $name = '';
    $shortcut = '';
    extract($_GET);
    include RMTemplate::get()->get_template('admin/shop_categories.php', 'module', 'shop');
    RMTemplate::get()->assign('xoops_pagetitle', __('Categories Management', 'shop'));
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    xoops_cp_footer();
}
 /**
  * Insert a new ShopCategory into the database.
  *
  * @static
  * @param   string      $catName    The new ShopCategory name
  * @param   integer     $catParent  The parent ShopCategory ID
  * @return  integer                 The ID of the new ShopCategory,
  *                                  or 0 on failure.
  * @author  Unknown <*****@*****.**> (Original author)
  * @author  Reto Kohli <*****@*****.**> (Made static)
  */
 static function InsertNewCat($catName, $catParent)
 {
     $objCategory = new ShopCategory($catName, '', $catParent);
     if ($objCategory->store()) {
         return $objCategory->id();
     }
     return 0;
 }
Beispiel #3
0
        }
        $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 &#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();