Пример #1
0
 /**
  * Get results
  */
 public function latest_results($cat = 0, $c = 0, $limit = 0)
 {
     if ($c <= 0) {
         $champ = self::current_championship();
     } else {
         $champ = new MCHChampionship($c);
     }
     if (!is_object($champ)) {
         $champ = self::last_championship();
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $tbr = $db->prefix("mch_role");
     $tbs = $db->prefix("mch_score");
     $sql = "SELECT a.*, s.item, s.local as loc, s.visitor as vis, s.win, s.champ FROM {$tbr} as a, {$tbs} as s WHERE a.champ='" . $champ->id() . "' AND a.time<" . time();
     if ($cat > 0) {
         $sql .= " AND a.category='" . $cat . "'";
     }
     $sql .= " AND s.item=a.id_role ORDER BY a.time DESC LIMIT 0, {$limit}";
     $result = $db->query($sql);
     $tf = new RMTimeFormatter();
     while ($row = $db->fetchArray($result)) {
         $local = new MCHTeam($row['local']);
         $visitor = new MCHTeam($row['visitor']);
         $category = new MCHCategory($row['category']);
         $field = new MCHField($row['field']);
         $data[] = array('local' => array('id' => $local->id(), 'name' => $local->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $local->getVar('logo'), 'score' => $row['loc']), 'visitor' => array('id' => $visitor->id(), 'name' => $visitor->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $visitor->getVar('logo'), 'score' => $row['vis']), 'day' => $tf->format($row['time'], __('%M% %d%', 'match')), 'hour' => $tf->format($row['time'], __('%h%:%i%', 'match')), 'category' => array('name' => $category->getVar('name'), 'link' => $category->permalink()), 'field' => $field->getVar('name'), 'win' => $row['win']);
     }
     return $data;
 }
Пример #2
0
function m_field_form($edit = 0)
{
    global $xoopsModule, $xoopsModuleConfig;
    MCHFunctions::toolbar();
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Field', 'match') : __('Add Field', 'match'));
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; \n        <a href='fields.php'>" . __('Fields', 'match') . '</a> &raquo; ' . ($edit ? __('Edit Field', 'match') : __('Add Field', 'match')));
    xoops_cp_header();
    $id = rmc_server_var($_REQUEST, 'id', 0);
    if ($edit) {
        //Verificamos si la categoría es válida
        if ($id <= 0) {
            redirectMsg('./fields.php', __('Provide a field ID!', 'match'), 1);
            die;
        }
        //Verificamos si la categoría existe
        $field = new MCHField($id);
        if ($field->isNew()) {
            redirectMsg('./fields.php', __('Specified field was not found!', 'match'), 1);
            die;
        }
    }
    $form = new RMForm($edit ? __('Edit Field', 'match') : __('Add Field', 'match'), 'frmNew', 'fields.php');
    $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 200, $edit ? $field->getVar('name') : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 200, $field->getVar('nameid')), true);
    }
    $form->addElement(new RMFormEditor(__('Description', 'match'), 'description', '100%', '250px', $edit ? $field->getVar('description', 'e') : ''));
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $field->id()));
    }
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit');
    $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'fields.php\';"');
    $form->addElement($ele);
    $form = RMEvents::get()->run_event('match.form.fields', $form);
    $form->display();
    RMTemplate::get()->add_style('admin.css', 'match');
    xoops_cp_footer();
}