Exemplo n.º 1
0
/**
* @desc Muestra todas las publicaciones existentes
**/
function show_resources()
{
    global $xoopsModule, $xoopsConfig, $xoopsSecurity;
    $query = rmc_server_var($_REQUEST, 'query', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Navegador de páginas
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_resources');
    if ($query) {
        $sql .= " WHERE title LIKE '%query%'";
    }
    list($num) = $db->fetchRow($db->queryF($sql));
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = 15;
    $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('resources.php?page={PAGE_NUM}');
    //Fin navegador de páginas
    $sql = "SELECT * FROM " . $db->prefix('rd_resources') . ($query != '' ? " WHERE title LIKE '%{$query}%'" : '') . " ORDER BY `created` DESC LIMIT {$start},{$limit}";
    $result = $db->queryF($sql);
    $resources = array();
    while ($rows = $db->fetchArray($result)) {
        $res = new RDResource();
        $res->assignVars($rows);
        $resources[] = array('id' => $res->id(), 'title' => $res->getVar('title'), 'created' => formatTimestamp($res->getVar('created'), 'm'), 'public' => $res->getVar('public'), 'quick' => $res->getVar('quick'), 'approvededit' => $res->getVar('editor_approve'), 'featured' => $res->getVar('featured'), 'approved' => $res->getVar('approved'), 'owname' => $res->getVar('owname'), 'owner' => $res->getVar('owner'), 'description' => $res->getVar('description'), 'sections' => $res->sections_count(), 'notes' => $res->notes_count(), 'figures' => $res->figures_count());
    }
    RMTemplate::get()->add_style('admin.css', 'docs');
    RMTemplate::get()->assign('xoops_pagetitle', __('Documents', 'docs'));
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_script(XOOPS_URL . '/modules/docs/include/js/admin.js');
    RMTemplate::get()->add_head('<script type="text/javascript">
    var rd_message = "' . __('Do you really wish to delete selected Documents?', 'docs') . '";
    var rd_select_message = "' . __('You must select an element before to do this action!', 'docs') . '";
    </script>');
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Documents', 'docs'));
    RDFunctions::toolbar();
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/rd_resources.php', 'module', 'docs');
    xoops_cp_footer();
}