function mch_ranking_bkedit($options) { $ch = $options[0]; $cat = $options[1]; $limit = $options[2]; include_once XOOPS_ROOT_PATH . '/modules/match/class/mchfunctions.php'; $form = '<label><strong>' . __('Championship:', 'match') . '</strong><br />'; $form .= '<select name="options[0]">'; $form .= '<option value="0"' . ($ch == 0 ? ' selected="selected"' : '') . ">" . __('From user selected', 'match') . '</option>'; $champs = MCHFunctions::all_championships(); foreach ($champs as $c) { $form .= '<option value="' . $c['id'] . '"' . ($ch == $c['id'] ? ' selected="selected"' : '') . '>' . $c['name'] . '</option>'; } $form .= '</select></label><br /><br />'; $form .= '<label><strong>' . __('Category', 'match') . '</strong><br />'; $form .= '<select name="options[1]">'; $form .= '<option value="0"' . ($cat == 0 ? ' selected="selected"' : '') . ">" . __('From user selected', 'match') . '</option>'; $categories = array(); MCHFunctions::categories_tree($categories); foreach ($categories as $c) { $form .= '<option value="' . $c['id_cat'] . '"' . ($cat == $c['id_cat'] ? ' selected="selected"' : '') . '>' . str_repeat("—", $c['indent']) . $c['name'] . '</option>'; } $form .= '</select></label><br /><br />'; $form .= '<label><strong>' . __('Number of items:', 'match') . '</strong> '; $form .= '<input type="text" name="options[3]" value="' . $limit . '" size="5" />'; return $form; }
/** * Show the form to edit or create a category * @param int edit */ function m_categories_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Category', 'match') : __('Add Category', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='categories.php'>" . __('Categories', 'match') . '</a> » ' . ($edit ? __('Edit Category', 'match') : __('Add Category', '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('./categories.php', __('Provide a category ID!', 'match'), 1); die; } //Verificamos si la categoría existe $cat = new MCHCategory($id); if ($cat->isNew()) { redirectMsg('./categories.php', __('Specified category was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Category', 'match') : __('Add Category', 'match'), 'frmNew', 'categories.php'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $cat->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $cat->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Description', 'match'), 'desc', '100%', '250px', $edit ? $cat->getVar('description', 'e') : '')); $sel_cats = new RMFormSelect(__('Parent category:', 'match'), 'parent', 0, $edit ? $cat->getVar('parent') : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, $edit ? $cat->id() : 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $cat->getVar('parent') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats); $form->addElement(new RMFormYesNo(__('Enable category', 'match'), 'active', $edit ? $cat->getVar('active') : 1)); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $cat->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'categos.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.categories', $form); $form->display(); xoops_cp_footer(); }
/** * Get categories tree * @param int Id of the category where search must start * @return array */ public function categories_tree(&$categories, $parent = 0, $indent = 0, $include_subs = true, $exclude = 0, $order = "id_cat DESC") { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mch_categories") . " WHERE parent='{$parent}' ORDER BY {$order}"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { if ($row['id_cat'] == $exclude) { continue; } $cat = new MCHCategory(); $cat->assignVars($row); $row['indent'] = $indent; $row['link'] = $cat->permalink(); $row['description'] = $cat->getVar('description'); $row['id'] = $cat->id(); $categories[$row['id_cat']] = $row; if ($include_subs) { MCHFunctions::categories_tree($categories, $row['id_cat'], $indent + 1, $include_subs, $exclude); } } }
function m_show_ranking() { global $xoopsModule; $champ = rmc_server_var($_REQUEST, 'champ', 0); $category = rmc_server_var($_REQUEST, 'category', 0); $champs = MCHFunctions::all_championships(); $categories = array(); MCHFunctions::categories_tree($categories); if ($champ > 0 && $category > 0) { $ranking = MCHFunctions::get_ranking($champ, $category); } MCHFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Coaches', 'match')); RMTemplate::get()->assign('xoops_pagetitle', __('Coaches', '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 coaches?', 'match') . "';\n\n var mch_select_message = '" . __('You must select some coach 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_ranking.php", 'module', 'match'); xoops_cp_footer(); }
function m_teams_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Team', 'match') : __('Add Team', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='teams.php'>" . __('Teams', 'match') . '</a> » ' . ($edit ? __('Edit Team', 'match') : __('Add Team', '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('./teams.php', __('Provide a team ID!', 'match'), 1); die; } //Verificamos si la categoría existe $team = new MCHTeam($id); if ($team->isNew()) { redirectMsg('./teams.php', __('Specified team was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Team', 'match') : __('Add Team', 'match'), 'frmNew', 'teams.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $team->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $team->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Team Information', 'match'), 'info', '100%', '250px', $edit ? $team->getVar('info', 'e') : '')); $sel_cats = new RMFormSelect(__('Category:', 'match'), 'category', 0, $edit ? array($team->getVar('category')) : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $team->getVar('category') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats, true); $form->addElement(new RMFormYesNo(__('Active', 'match'), 'active', $edit ? $team->getVar('active') : 1)); $form->addElement(new RMFormDate(__('Registered on', 'match'), 'created', $edit ? $team->getVar('created') : time(), false)); $form->addElement(new RMFormFile(__('Team logo', 'match'), 'logo', 45)); if ($edit) { $form->addElement(new RMFormLabel(__('Current logo', 'match'), '<img src="' . MCH_UP_URL . '/' . $team->getVar('logo') . '" alt="' . $team->getVar('name') . '" />')); } $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $team->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'teams.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.teams', $form); $form->display(); xoops_cp_footer(); }
// 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'))); // Results $data = MCHFunctions::latest_results($category->id(), $champ->id(), 20); $xoopsTpl->assign('results', $data); $categories = array(); MCHFunctions::categories_tree($categories); foreach ($categories as $k => $cat) { $categories[$k]['guion'] = str_repeat("—", $cat['indent']); } $xoopsTpl->assign('categories', $categories); // Championships $xoopsTpl->assign('champs', MCHFunctions::all_championships()); // Constants $xoopsTpl->assign('mch_upurl', MCH_UP_URL); // Language $xoopsTpl->assign('lang_ranking', __('Ranking', 'match')); $xoopsTpl->assign('lang_results', __('Results', 'match')); $xoopsTpl->assign('lang_wons', __('Won matches:', 'match')); $xoopsTpl->assign('lang_netxmatches', __('Next Matches', 'match')); $xoopsTpl->assign('lang_local', __('Local Team', 'match')); $xoopsTpl->assign('lang_visitor', __('Visitor Team', 'match'));
function m_show_roleplay() { global $xoopsModule, $xoopsModuleConfig, $xoopsSecurity; $champ = rmc_server_var($_REQUEST, 'champ', 0); $category = rmc_server_var($_REQUEST, 'category', 0); $team = rmc_server_var($_REQUEST, 'team', 0); $sday = rmc_server_var($_REQUEST, 'sday', 0); $db = XoopsDatabaseFactory::getDatabaseConnection(); $champs = MCHFunctions::all_championships(); // Select role item if ($champ > 0 && $category > 0) { $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ . "' AND category='" . $category . "'"; if ($team > 0) { $sql .= " AND (local='{$team}' OR visitor='{$team}')"; } if ($sday > 0) { $sql .= " AND time<={$sday} AND time>=" . ($sday - 86400); } $sql .= " ORDER BY `time`"; $result = $db->query($sql); $role = array(); $tcache = array(); $fcache = array(); $tf = new RMTimeFormatter('', __('%M% %d%, %Y% - %h%:%i%', 'match')); $i = 0; $days = array(); $pday = 0; while ($row = $db->fetchArray($result)) { $item = new MCHRoleItem(); $item->assignVars($row); if (isset($tcache[$item->getVar('local')])) { $local = $tcache[$item->getVar('local')]; } else { $tcache[$item->getVar('local')] = new MCHTeam($item->getVar('local')); $local = $tcache[$item->getVar('local')]; } if (isset($tcache[$item->getVar('visitor')])) { $visitor = $tcache[$item->getVar('visitor')]; } else { $tcache[$item->getVar('visitor')] = new MCHTeam($item->getVar('visitor')); $visitor = $tcache[$item->getVar('visitor')]; } if (isset($fcache[$item->getVar('field')])) { $field = $fcache[$item->getVar('field')]; } else { $fcache[$item->getVar('field')] = new MCHField($item->getVar('field')); $field = $fcache[$item->getVar('field')]; } $role[$i] = array('id' => $item->id(), 'local' => array('id' => $local->id(), 'logo' => MCH_UP_URL . '/' . $local->getVar('logo'), 'name' => $local->getVar('name')), 'visitor' => array('id' => $visitor->id(), 'logo' => MCH_UP_URL . '/' . $visitor->getVar('logo'), 'name' => $visitor->getVar('name')), 'date' => $tf->format($item->getVar('time')), 'hour' => $tf->format($item->getVar('time'), '%h%:%i%'), 'time' => $item->getVar('time'), 'field' => array('id' => $field->id(), 'name' => $field->getVar('name')), 'past' => $item->getVar('time') < time() ? true : false); if ($role[$i]['past']) { $score = new MCHScoreItem(); $score->byRole($item->id()); $role[$i]['local']['score'] = $score->getVar('local'); $role[$i]['visitor']['score'] = $score->getVar('visitor'); } // Add days to combo if ($pday <= 0) { $pday = mktime(0, 0, 1, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); $days[] = $pday; } $now = mktime(23, 59, 0, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); if ($now > $pday + 86400) { $pday = $now; $days[] = $pday; } $i++; } } // Charge days if incomplete if ($champ > 0 && $category > 0 && $sday > 0) { $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ . "' AND category='" . $category . "'"; if ($team > 0) { $sql .= " AND (local='{$team}' OR visitor='{$team}')"; } $sql .= " ORDER BY `time`"; $result = $db->query($sql); $days = array(); $pday = 0; while ($row = $db->fetchArray($result)) { $item = new MCHRoleItem(); $item->assignVars($row); // Add days to combo if ($pday <= 0) { $pday = mktime(0, 0, 1, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); $days[] = $pday; } $now = mktime(23, 59, 0, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); if ($now > $pday + 86400) { $pday = $now; $days[] = $pday; } } } // Categories $categories = array(); MCHFunctions::categories_tree($categories); // Teams $teams = MCHFunctions::all_teams(false, 'category=' . $category); // Fields $fields = MCHFunctions::all_fields(); // Date field $form = new RMForm('', '', ''); $datetime = new RMFormDate('', 'date', '', '', 1); $datetime->options('stepMinute: 15'); MCHFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Role Play', 'match')); RMTemplate::get()->assign('xoops_pagetitle', __('Coaches', '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 items?', 'match') . "';\n\n var mch_select_message = '" . __('You must select some role item 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_roleplay.php", 'module', 'match'); xoops_cp_footer(); }