Ejemplo n.º 1
0
function m_championship_form($edit = 0)
{
    global $xoopsModule, $xoopsModuleConfig;
    MCHFunctions::toolbar();
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Championship', 'match') : __('Add Championship', 'match'));
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; \n        <a href='champ.php'>" . __('Championships', 'match') . '</a> &raquo; ' . ($edit ? __('Edit Championship', 'match') : __('Add Championship', '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('./champ.php', __('Provide a championship ID!', 'match'), 1);
            die;
        }
        //Verificamos si la categoría existe
        $champ = new MCHChampionship($id);
        if ($champ->isNew()) {
            redirectMsg('./champ.php', __('Specified championship was not found!', 'match'), 1);
            die;
        }
    }
    $form = new RMForm($edit ? __('Edit Championship', 'match') : __('Add Championship', 'match'), 'frmNew', 'champ.php');
    $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 200, $edit ? $champ->getVar('name') : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 200, $champ->getVar('nameid')), true);
    }
    $form->addElement(new RMFormEditor(__('Description', 'match'), 'description', '100%', '250px', $edit ? $champ->getVar('description', 'e') : ''));
    $form->addElement(new RMFormDate(__('Start date', 'match'), 'start', $edit ? $champ->getVar('start') : 0), true);
    $form->addElement(new RMFormDate(__('End date', 'match'), 'end', $edit ? $champ->getVar('end') : 0), true);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $champ->id()));
    }
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit');
    $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'champ.php\';"');
    $form->addElement($ele);
    $form = RMEvents::get()->run_event('match.form.championships', $form);
    $form->display();
    RMTemplate::get()->add_style('admin.css', 'match');
    xoops_cp_footer();
}
Ejemplo n.º 2
0
 /**
  * Get next matches
  * 
  * @param int Category identifier
  * @param int Number of items per category
  * @param int Championship identifier. If not is provided or 0 is provided then will be used the current championship.
  * @return array
  */
 public function next_matches($cat = 0, $c = 0, $limit = 0, $team = 0)
 {
     if ($c <= 0) {
         $champ = self::current_championship();
     } else {
         $champ = new MCHChampionship($c);
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ->id() . "' AND time>=" . time();
     if ($cat > 0) {
         $sql .= " AND category='" . $cat . "'";
     }
     if ($team > 0) {
         $sql .= " AND (local={$team} OR visitor={$team})";
     }
     $sql .= " ORDER BY time";
     if ($limit > 0) {
         $sql .= " LIMIT 0,{$limit}";
     }
     $result = $db->query($sql);
     $data = array();
     $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('name' => $local->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $local->getVar('logo'), 'id' => $local->id()), 'visitor' => array('name' => $visitor->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $visitor->getVar('logo'), 'id' => $visitor->id()), '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'));
     }
     return $data;
 }
Ejemplo n.º 3
0
// License: GPL 2.0
// --------------------------------------------------------------
include 'header.php';
$xoopsOption['template_main'] = "mch_rol.html";
$xoopsOption['module_subpage'] = 'index';
include XOOPS_ROOT_PATH . '/header.php';
// Get current match
$id_champ = rmc_server_var($_REQUEST, 'ch', 0);
if ($id_champ <= 0) {
    $champ = MCHFunctions::current_championship();
} else {
    $champ = new MCHChampionship($id_champ);
}
// Time Formatter
$tf = new RMTimeFormatter(0, __('%M% %d%, %Y%', 'match'));
$xoopsTpl->assign('champ', array('id' => $champ->id(), 'name' => $champ->getVar('name'), 'start' => $tf->format($champ->getVar('start')), 'end' => $tf->format($champ->getVar('end'))));
// Get category
$id_cat = rmc_server_var($_REQUEST, 'cat', 0);
if ($id_cat > 0) {
    $category = new MCHCategory($id_cat);
} else {
    $category = MCHFunctions::first_category();
}
$xoopsTpl->assign('category', array('id' => $category->id(), 'name' => $category->getVar('name'), 'desc' => $category->getVar('description')));
// Get category
$id_team = rmc_server_var($_REQUEST, 'team', 0);
if ($id_team > 0) {
    $team = new MCHTeam($id_team);
    $xoopsTpl->assign('team', array('id' => $team->id(), 'name' => $team->getVar('name'), 'desc' => $team->getVar('info')));
}
// Role