Пример #1
0
function show_categories()
{
    global $xoopsModule, $xoopsModuleConfig, $xoopsConfig, $xoopsSecurity;
    $db = Database::getInstance();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("rmc_img_cats");
    /**
     * Paginacion de Resultados
     */
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = $xoopsModuleConfig['catsnumber'];
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('images.php?action=showcats&page={PAGE_NUM}');
    // Get categories
    $sql = "SELECT * FROM " . $db->prefix("rmc_img_cats") . " ORDER BY id_cat DESC LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $categories = array();
    while ($row = $db->fetchArray($result)) {
        $cat = new RMImageCategory();
        $cat->assignVars($row);
        $groups = $cat->getVar('groups');
        $categories[] = array('id' => $cat->id(), 'name' => $cat->getVar('name'), 'status' => $cat->getVar('status'), 'gwrite' => RMFunctions::get_groups_names($groups['write']), 'gread' => RMFunctions::get_groups_names($groups['read']), 'sizes' => $cat->getVar('sizes'), 'images' => RMFunctions::get_num_records('rmc_images', 'cat=' . $cat->id()));
    }
    RMTemplate::get()->add_style('general.css', 'rmcommon');
    RMTemplate::get()->add_style('imgmgr.css', 'rmcommon');
    RMTemplate::get()->add_script('include/js/jquery.checkboxes.js');
    RMFunctions::create_toolbar();
    xoops_cp_header();
    include RMTemplate::get()->get_template('images_categories.php', 'module', 'rmcommon');
    xoops_cp_footer();
}