Beispiel #1
0
function m_show_championships()
{
    global $xoopsModule, $xoopsSecurity;
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $page = $page <= 0 ? 1 : $page;
    $limit = 15;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('mch_champs');
    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('champ.php?page={PAGE_NUM}');
    $champs = array();
    $sql = str_replace('COUNT(*)', '*', $sql);
    $sql .= ' ORDER BY start DESC,name ASC';
    $result = $db->query($sql);
    $timef = new RMTimeFormatter('', "%M% %d%, %Y%");
    while ($row = $db->fetchArray($result)) {
        $champ = new MCHChampionship();
        $champ->assignVars($row);
        $champs[] = array('id' => $champ->id(), 'link' => $champ->permalink(), 'name' => $champ->getVar('name'), 'nameid' => $champ->getVar('nameid'), 'start' => $timef->format($champ->getVar('start')), 'end' => $timef->format($champ->getVar('end')), 'description' => $champ->getVar('description'), 'current' => $champ->getVar('current'));
    }
    $form = new RMForm('', '', '');
    $editor = new RMFormEditor('', 'description', '98%', '200px', '', 'html');
    $start = new RMFormDate('', 'start', time());
    $end = new RMFormDate('', 'end', time());
    MCHFunctions::toolbar();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Championships', 'match'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Championships', 'match'));
    RMTemplate::get()->add_style('admin.css', 'match');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_local_script('admin_match.js', 'match');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar mch_message='" . __('Do you really want to delete selected championships?', 'match') . "';\n\n        var mch_select_message = '" . __('You must select some championships before to execute this action!', 'match') . "';</script>");
    xoops_cp_header();
    $match_extra_options = RMEvents::get()->run_event('match.more.options');
    include RMTemplate::get()->get_template("admin/mch_champs.php", 'module', 'match');
    xoops_cp_footer();
}
 public function last_championship()
 {
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("mch_champs") . " ORDER BY id_champ DESC LIMIT 0,1";
     $result = $db->query($sql);
     if ($db->getRowsNum($result) <= 0) {
         return 0;
     }
     $row = $db->fetchArray($result);
     $champ = new MCHChampionship();
     $champ->assignVars($row);
     return $champ;
 }