/** * @desc Visualiza todas las postales existentes **/ function showPostCards() { global $xoopsModule, $tpl, $xoopsModuleConfig, $xoopsSecurity; $mc =& $xoopsModuleConfig; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $limit = $limit <= 0 ? 15 : $limit; $db = XoopsDatabaseFactory::getDatabaseConnection(); //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_postcards'); list($num) = $db->fetchRow($db->query($sql)); list($num) = $db->fetchRow($db->query($sql)); $start = $num <= 0 ? 0 : ($page - 1) * $limit; $tpages = ceil($num / $limit); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url("postcards.php?page={PAGE_NUM}&limit={$limit}"); //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_postcards'); $sql .= " LIMIT {$start},{$limit}"; $result = $db->query($sql); $posts = array(); $tf = new RMTimeFormatter(0, __('%M% %d%, %Y% - %h%:%i%:%s%', 'galleries')); while ($rows = $db->fetchArray($result)) { $post = new GSPostcard(); $post->assignVars($rows); $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&id=' . $post->code()); $posts[] = array('id' => $post->id(), 'title' => $post->title(), 'date' => $tf->format($post->date()), 'toname' => $post->toName(), 'name' => $post->email(), 'view' => $post->viewed(), 'link' => $link); } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('E-cards', 'galleries')); xoops_cp_header(); RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-postcards&', 'galleries'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected e-cards?', 'galleries') . "';\n</script>"); include RMTemplate::get()->get_template('admin/gs_postcards.php', 'module', 'galleries'); xoops_cp_footer(); }