コード例 #1
0
ファイル: class_match_htmlout.php プロジェクト: TheNAF/naflm
 public static function upcomingMatches()
 {
     global $lng;
     title($lng->getTrn('menu/matches_menu/upcoming'));
     list($node, $node_id) = HTMLOUT::nodeSelector(array());
     echo '<br>';
     HTMLOUT::upcomingGames(false, false, $node, $node_id, false, false, array('url' => 'index.php?section=matches&amp;type=upcoming', 'n' => MAX_RECENT_GAMES));
 }
コード例 #2
0
ファイル: class_coach_htmlout.php プロジェクト: TheNAF/naflm
 public static function dispList()
 {
     global $lng;
     /*
         NOTE: We do NOT show coaches not having played any matches for nodes = {T_NODE_TOURNAMENT, T_NODE_DIVISION}.
     */
     list($sel_node, $sel_node_id, $sel_state, $sel_race) = HTMLOUT::nodeSelector(array('state' => true));
     $ALL_TIME = $sel_node === false && $sel_node_id === false;
     $fields = 'coach_id AS "coach_id", coaches.name AS "cname", coaches.retired AS "retired", team_cnt AS "team_cnt"';
     $where = array();
     if ($sel_state == T_STATE_ACTIVE) {
         $where[] = 'coaches.retired IS FALSE';
     }
     if ($ALL_TIME) {
         $where = count($where) > 0 ? 'WHERE ' . implode(' AND ', $where) : '';
         $queryCnt = "SELECT COUNT(*) FROM coaches {$where}";
         $queryGet = "SELECT {$fields} FROM coaches {$where} ORDER BY cname ASC";
     } else {
         if ($sel_node == T_NODE_LEAGUE) {
             $where = count($where) > 0 ? ' AND ' . implode(' AND ', $where) : '';
             # In case of duplicate records in memberships table we search for distinct/"grouped by" values.
             $queryCnt = "SELECT COUNT(DISTINCT cid, lid) FROM coaches,memberships WHERE cid = coach_id AND lid = {$sel_node_id} {$where}";
             $queryGet = "SELECT {$fields} FROM coaches,memberships WHERE cid = coach_id AND lid = {$sel_node_id} {$where} GROUP BY cid, lid ORDER BY cname ASC";
         } else {
             $q = "SELECT {$fields} FROM matches, teams, coaches, tours, divisions \n              WHERE teams.owned_by_coach_id = coaches.coach_id AND matches._RRP = teams.team_id AND matches.f_tour_id = tours.tour_id AND tours.f_did = divisions.did ";
             switch ($sel_node) {
                 case false:
                     break;
                 case T_NODE_TOURNAMENT:
                     $q .= "AND tours.tour_id = {$sel_node_id}";
                     break;
                 case T_NODE_DIVISION:
                     $q .= "AND divisions.did = {$sel_node_id}";
                     break;
                 case T_NODE_LEAGUE:
                     $q .= "AND divisions.f_lid = {$sel_node_id}";
                     break;
             }
             $q .= count($where) > 0 ? ' AND ' . implode(' AND ', $where) . ' ' : '';
             $_subt1 = '(' . preg_replace('/\\_RRP/', 'team1_id', $q) . ')';
             $_subt2 = '(' . preg_replace('/\\_RRP/', 'team2_id', $q) . ')';
             $queryCnt = "SELECT COUNT(*) FROM (({$_subt1}) UNION DISTINCT ({$_subt2})) AS tmp";
             $queryGet = '(' . $_subt1 . ') UNION DISTINCT (' . $_subt2 . ') ORDER BY cname ASC';
         }
     }
     $result = mysql_query($queryCnt);
     list($cnt) = mysql_fetch_row($result);
     $pages = $cnt == 0 ? 1 : ceil($cnt / T_HTML_COACHES_PER_PAGE);
     global $page;
     $page = isset($_GET['page']) && $_GET['page'] <= $pages ? $_GET['page'] : 1;
     # Page 1 is default, of course.
     $_url = "?section=coachlist&amp;";
     echo '<br><center><table>';
     echo '<tr><td>';
     echo $lng->getTrn('common/page') . ': ' . implode(', ', array_map(create_function('$nr', 'global $page; return ($nr == $page) ? $nr : "<a href=\'' . $_url . 'page=$nr\'>$nr</a>";'), range(1, $pages)));
     echo '</td></td>';
     echo "<tr><td>" . $lng->getTrn('common/coaches') . ": {$cnt}</td></td>";
     echo '</table></center><br>';
     $queryGet .= ' LIMIT ' . ($page - 1) * T_HTML_COACHES_PER_PAGE . ', ' . $page * T_HTML_COACHES_PER_PAGE;
     $coaches = array();
     $result = mysql_query($queryGet);
     while ($c = mysql_fetch_object($result)) {
         $c->retired = $c->retired ? '<b>' . $lng->getTrn('common/yes') . '</b>' : $lng->getTrn('common/no');
         $coaches[] = $c;
     }
     $fields = array('cname' => array('desc' => $lng->getTrn('common/name'), 'nosort' => true, 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'coach_id')), 'team_cnt' => array('desc' => $lng->getTrn('common/teams'), 'nosort' => true), 'retired' => array('desc' => $lng->getTrn('common/retired'), 'nosort' => true));
     HTMLOUT::sort_table($lng->getTrn('common/coaches'), "index.php{$_url}", $coaches, $fields, array(), array(), array('doNr' => false, 'noHelp' => true, 'noSRdisp' => true));
 }
コード例 #3
0
    public static function makeList($ALLOW_EDIT)
    {
        global $lng, $coach, $settings;
        HTMLOUT::frame_begin(is_object($coach) ? $coach->settings['theme'] : $settings['stylesheet']);
        # Make page frame, banner and menu.
        /* A new entry was sent. Add it to system */
        if (isset($_POST['tid']) && $ALLOW_EDIT) {
            if (get_magic_quotes_gpc()) {
                $_POST['title'] = stripslashes($_POST['title']);
                $_POST['about'] = stripslashes($_POST['about']);
            }
            switch ($_GET['action']) {
                case 'edit':
                    $e = new self($_GET['ft_id']);
                    status($e->edit($_POST['title'], $_POST['about']));
                    break;
                case 'new':
                    status(self::create($_POST['tid'], $_POST['title'], $_POST['about']));
                    break;
            }
        }
        title($lng->getTrn('name', __CLASS__));
        /* Was a request for a new entry made? */
        if (isset($_GET['action']) && $ALLOW_EDIT) {
            // Default schema values. These are empty unless "edit" is chosen.
            $tid = false;
            $title = '';
            $about = '';
            switch ($_GET['action']) {
                case 'delete':
                    if (isset($_GET['ft_id']) && is_numeric($_GET['ft_id'])) {
                        $e = new self($_GET['ft_id']);
                        status($e->delete());
                        unset($e);
                    } else {
                        fatal('Sorry. You did not specify which FT-id you wish to delete.');
                    }
                    break;
                case 'edit':
                    if (isset($_GET['ft_id']) && is_numeric($_GET['ft_id'])) {
                        $e = new self($_GET['ft_id']);
                        $tid = $e->tid;
                        $title = $e->title;
                        $about = $e->about;
                        $_POST['lid'] = get_alt_col('mv_teams', 'f_tid', $tid, 'f_lid');
                    } else {
                        fatal('Sorry. You did not specify which FT-id you wish to edit.');
                    }
                    // Fall-through to "new" !!!
                // Fall-through to "new" !!!
                case 'new':
                    echo "<a href='handler.php?type=famousteams'><-- " . $lng->getTrn('common/back') . "</a><br><br>";
                    $_DISABLED = !isset($_POST['lid']) ? 'DISABLED' : '';
                    $node_id = isset($_POST['lid']) ? $_POST['lid'] : null;
                    ?>
                <form name="STS" method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('common/league');
                    ?>
</b><br>
                <?php 
                    echo HTMLOUT::nodeList(T_NODE_LEAGUE, 'lid', array(), array(), array('sel_id' => $node_id));
                    ?>
                <input type='submit' value='<?php 
                    echo $lng->getTrn('common/select');
                    ?>
'>
                </form>
                <br>
                <form method="POST">
                <b><?php 
                    echo $lng->getTrn('team', __CLASS__) . '</b>';
                    ?>
<br>
                <?php 
                    $query = "SELECT team_id, name FROM teams WHERE f_lid = {$node_id} ORDER by name ASC";
                    $result = mysql_query($query);
                    if ($result && mysql_num_rows($result) == 0) {
                        $_DISABLED = 'DISABLED';
                    }
                    ?>
                <select name="tid" id="teams" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    while ($row = mysql_fetch_assoc($result)) {
                        echo "<option value='{$row['team_id']}' " . ($tid == $row['team_id'] ? 'SELECTED' : '') . ">{$row['name']}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <b><?php 
                    echo $lng->getTrn('g_title', __CLASS__) . '</b>&nbsp;&mdash;&nbsp;' . $lng->getTrn('title', __CLASS__);
                    ?>
<br>
                <input type="text" name="title" size="60" maxlength="100" value="<?php 
                    echo $title;
                    ?>
" <?php 
                    echo $_DISABLED;
                    ?>
>
                <br><br>
                <b><?php 
                    echo $lng->getTrn('g_about', __CLASS__) . '</b>&nbsp;&mdash;&nbsp;' . $lng->getTrn('about', __CLASS__);
                    ?>
<br>
                <textarea name="about" rows="15" cols="100" <?php 
                    echo $_DISABLED;
                    ?>
><?php 
                    echo $about;
                    ?>
</textarea>
                <br><br>
                <input type="submit" value="<?php 
                    echo $lng->getTrn('submit', __CLASS__);
                    ?>
" name="Submit" <?php 
                    echo $_DISABLED;
                    ?>
>
                </form>
                <?php 
                    return;
                    break;
            }
        }
        /* Print the hall of fame */
        echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n";
        list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array());
        if ($ALLOW_EDIT) {
            echo "<br><a href='handler.php?type=famousteams&amp;action=new'>" . $lng->getTrn('new', __CLASS__) . "</a><br>\n";
        }
        self::printList($sel_node, $sel_node_id, $ALLOW_EDIT);
        HTMLOUT::frame_end();
    }
コード例 #4
0
ファイル: class_prize.php プロジェクト: TheNAF/naflm
    public static function makeList()
    {
        global $lng, $coach, $settings;
        HTMLOUT::frame_begin();
        # Make page frame, banner and menu.
        title($lng->getTrn('name', __CLASS__));
        echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n";
        list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array());
        $ALLOW_EDIT = is_object($coach) && $coach->isNodeCommish($sel_node, $sel_node_id);
        /* A new entry was sent. Add it to system */
        if ($ALLOW_EDIT && isset($_POST['tid']) && isset($_POST['trid'])) {
            if (get_magic_quotes_gpc()) {
                $_POST['title'] = stripslashes($_POST['title']);
                $_POST['txt'] = stripslashes($_POST['txt']);
            }
            switch ($_GET['action']) {
                case 'new':
                    status(self::create($_POST['ptype'], $_POST['tid'], $_POST['trid'], $_POST['title'], $_POST['txt']));
                    break;
            }
        }
        /* Was a request for a new entry made? */
        if (isset($_GET['action']) && $ALLOW_EDIT) {
            switch ($_GET['action']) {
                case 'delete':
                    if (isset($_GET['prid']) && is_numeric($_GET['prid'])) {
                        $pr = new Prize($_GET['prid']);
                        status($pr->delete());
                        unset($pr);
                    } else {
                        fatal('Sorry. You did not specify which prize ID you wish to delete.');
                    }
                    break;
                case 'new':
                    echo "<a href='handler.php?type=prize'><-- " . $lng->getTrn('common/back') . "</a><br><br>";
                    $_DISABLED = !isset($_POST['trid']) ? 'DISABLED' : '';
                    ?>
                <form name="STS" method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('common/tournament');
                    ?>
</b><br>
                <?php 
                    echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid');
                    ?>
                <input type='submit' value='<?php 
                    echo $lng->getTrn('common/select');
                    ?>
'>
                </form>
                <br>
                <form method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('team', __CLASS__);
                    ?>
</b><br>
                <select name="tid" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    $teams = isset($_POST['trid']) ? Team::getTeams(false, array(get_parent_id(T_NODE_TOURNAMENT, (int) $_POST['trid'], T_NODE_LEAGUE)), true) : array();
                    foreach ($teams as $tid => $name) {
                        echo "<option value='{$tid}'>{$name}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <b><?php 
                    echo $lng->getTrn('kind', __CLASS__);
                    ?>
</b><br>
                <select name="ptype" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    foreach (self::getTypes() as $ptype => $desc) {
                        echo "<option value='{$ptype}'>{$desc}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_title', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('title', __CLASS__);
                    ?>
<br>
                <input type="text" name="title" size="60" maxlength="100" value="" <?php 
                    echo $_DISABLED;
                    ?>
>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_about', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('about', __CLASS__);
                    ?>
<br>
                <textarea name="txt" rows="15" cols="100" <?php 
                    echo $_DISABLED;
                    ?>
></textarea>
                <br><br><br>
                <input type='hidden' name='trid' value='<?php 
                    echo $_DISABLED ? 0 : $_POST['trid'];
                    ?>
'>
                <input type="submit" value="<?php 
                    echo $lng->getTrn('submit', __CLASS__);
                    ?>
" name="Submit" <?php 
                    echo $_DISABLED;
                    ?>
>
                </form>
                <br>
                <?php 
                    return;
                    break;
            }
        }
        if ($ALLOW_EDIT) {
            echo "<br><a href='handler.php?type=prize&amp;action=new'>" . $lng->getTrn('new', __CLASS__) . "</a><br>\n";
        }
        /* Print the prizes */
        self::printList($sel_node, $sel_node_id, $ALLOW_EDIT);
        HTMLOUT::frame_end();
    }
コード例 #5
0
 public static function dispList()
 {
     global $lng;
     /*
         NOTE: We do NOT show teams not having played any matches for nodes = {T_NODE_TOURNAMENT, T_NODE_DIVISION}.
     */
     list($sel_node, $sel_node_id, $sel_state, $sel_race) = HTMLOUT::nodeSelector(array('race' => true, 'state' => true));
     $ALL_TIME = $sel_node === false && $sel_node_id === false;
     $fields = '_RRP AS "team_id", owned_by_coach_id, f_race_id, teams.name AS "tname", f_cname, f_rname, tv, teams.rdy AS "rdy", teams.retired AS "retired"';
     $where = array();
     if ($sel_state == T_STATE_ACTIVE) {
         $where[] = 'teams.rdy IS TRUE AND teams.retired IS FALSE';
     }
     if ($sel_race != T_RACE_ALL) {
         $where[] = "teams.f_race_id = {$sel_race}";
     }
     if ($sel_node == T_NODE_LEAGUE || $ALL_TIME) {
         if (!$ALL_TIME) {
             $where[] = "f_lid = {$sel_node_id}";
         }
         $where = count($where) > 0 ? 'WHERE ' . implode(' AND ', $where) : '';
         $queryCnt = "SELECT COUNT(*) FROM teams {$where}";
         $queryGet = 'SELECT ' . preg_replace('/\\_RRP/', 'team_id', $fields) . ' FROM teams ' . $where . ' ORDER BY tname ASC';
     } else {
         $q = "SELECT {$fields} FROM matches, teams, tours, divisions WHERE matches._RRP = teams.team_id AND matches.f_tour_id = tours.tour_id AND tours.f_did = divisions.did ";
         switch ($sel_node) {
             case false:
                 break;
             case T_NODE_TOURNAMENT:
                 $q .= "AND tours.tour_id = {$sel_node_id}";
                 break;
             case T_NODE_DIVISION:
                 $q .= "AND divisions.did = {$sel_node_id}";
                 break;
             case T_NODE_LEAGUE:
                 $q .= "AND divisions.f_lid = {$sel_node_id}";
                 break;
         }
         $q .= (count($where) > 0 ? ' AND ' : ' ') . implode(' AND ', $where) . ' ';
         $_subt1 = '(' . preg_replace('/\\_RRP/', 'team1_id', $q) . ')';
         $_subt2 = '(' . preg_replace('/\\_RRP/', 'team2_id', $q) . ')';
         $queryCnt = "SELECT COUNT(*) FROM (({$_subt1}) UNION DISTINCT ({$_subt2})) AS tmp";
         $queryGet = '(' . $_subt1 . ') UNION DISTINCT (' . $_subt2 . ') ORDER BY tname ASC';
     }
     $result = mysql_query($queryCnt);
     list($cnt) = mysql_fetch_row($result);
     $pages = $cnt == 0 ? 1 : ceil($cnt / T_HTML_TEAMS_PER_PAGE);
     global $page;
     $page = isset($_GET['page']) && $_GET['page'] <= $pages ? $_GET['page'] : 1;
     # Page 1 is default, of course.
     $_url = "?section=teamlist&amp;";
     echo '<br><center><table>';
     echo '<tr><td>';
     echo $lng->getTrn('common/page') . ': ' . implode(', ', array_map(create_function('$nr', 'global $page; return ($nr == $page) ? $nr : "<a href=\'' . $_url . 'page=$nr\'>$nr</a>";'), range(1, $pages)));
     echo '</td></td>';
     echo "<tr><td>" . $lng->getTrn('common/teams') . ": {$cnt}</td></td>";
     echo '</table></center><br>';
     $queryGet .= ' LIMIT ' . ($page - 1) * T_HTML_TEAMS_PER_PAGE . ', ' . $page * T_HTML_TEAMS_PER_PAGE;
     $teams = array();
     $result = mysql_query($queryGet);
     while ($t = mysql_fetch_object($result)) {
         $img = new ImageSubSys(IMGTYPE_TEAMLOGO, $t->team_id);
         $t->logo = "<img border='0px' height='20' width='20' alt='Team race picture' src='" . $img->getPath($t->f_race_id) . "'>";
         $retired = $t->retired;
         $t->retired = $t->retired ? '<b>' . $lng->getTrn('common/yes') . '</b>' : $lng->getTrn('common/no');
         $t->rdy = $t->rdy && !$retired ? '<font color="green">' . $lng->getTrn('common/yes') . '</font>' : '<font color="red">' . $lng->getTrn('common/no') . '</font>';
         $t->f_rname = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $t->f_rname)));
         $teams[] = $t;
     }
     $fields = array('logo' => array('desc' => 'Logo', 'nosort' => true, 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'team_id'), 'nosort' => true), 'tname' => array('desc' => $lng->getTrn('common/name'), 'nosort' => true, 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'team_id')), 'f_cname' => array('desc' => $lng->getTrn('common/coach'), 'nosort' => true, 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'owned_by_coach_id')), 'rdy' => array('desc' => $lng->getTrn('common/ready'), 'nosort' => true), 'retired' => array('desc' => $lng->getTrn('common/retired'), 'nosort' => true), 'f_rname' => array('desc' => $lng->getTrn('common/race'), 'nosort' => true, 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_RACE, false, false, false), 'field' => 'obj_id', 'value' => 'f_race_id')), 'tv' => array('desc' => 'TV', 'nosort' => true, 'kilo' => true, 'suffix' => 'k'));
     HTMLOUT::sort_table($lng->getTrn('common/teams'), "index.php{$_url}", $teams, $fields, array(), array(), array('doNr' => false, 'noHelp' => true, 'noSRdisp' => true));
 }
コード例 #6
0
ファイル: class_htmlout.php プロジェクト: nicholasmr/obblm
 public static function standings($obj, $node, $node_id, array $opts)
 {
     /*
         Makes various kinds of standings tables.
         $obj and $node types are STATS_* types.
     
         $opts = array(
            'url' => page URL on which table is to be displayed (required!)
            'GET_SS' => GET Sorting suffix
            'return_objects' => bool
            'teams_from' => [T_OBJ_COACH|T_OBJ_RACE] when $obj = T_OBJ_TEAM and this is set, only teams related to this object type (teams_from), of ID = $opts[teams_from_id] are fetched.
            'teams_from_id' => ID (int) see "teams_from" for details.
         );
     */
     global $lng, $settings, $objFields_avg;
     $tblTitle = '';
     $objs = $fields = $extra = array();
     $fields_before = $fields_after = array();
     // To be merged with $fields.
     if (!array_key_exists('GET_SS', $opts)) {
         $opts['GET_SS'] = '';
     } else {
         $extra['GETsuffix'] = $opts['GET_SS'];
     }
     # GET Sorting Suffix
     $PAGE = isset($_GET["page"]) ? (int) $_GET["page"] : 1;
     $PAGELENGTH = 0;
     # Infinite, is overrided in below switch/case..
     $extra['noHelp'] = false;
     $W_TEAMS_FROM = array_key_exists('teams_from', $opts);
     $enableRaceSelector = $obj == T_OBJ_PLAYER || $obj == T_OBJ_TEAM && (!isset($opts['teams_from']) || $opts['teams_from'] != T_OBJ_RACE);
     # NO filters for teams of a coach on the coach's teams list.
     $_COACH_TEAM_LIST = $W_TEAMS_FROM && $opts['teams_from'] == T_OBJ_COACH;
     if ($_COACH_TEAM_LIST) {
         list(, , $T_STATE) = HTMLOUT::nodeSelector(array('nonodes' => true, 'state' => true));
         # Produces a state selector.
         $_SELECTOR = array(false, false, $T_STATE, T_RACE_ALL, 'GENERAL', 'mv_played', self::T_NS__ffilter_ineq_gt, 0);
     } else {
         $_SELECTOR = HTMLOUT::nodeSelector(array('force_node' => array($node, $node_id), 'race' => $enableRaceSelector, 'sgrp' => true, 'ffilter' => true, 'obj' => $obj));
     }
     list($sel_node, $sel_node_id, $sel_state, $sel_race, $sel_sgrp, $sel_ff_field, $sel_ff_ineq, $sel_ff_limit) = $_SELECTOR;
     $filter_node = array($sel_node => $sel_node_id);
     $filter_race = $sel_race != T_RACE_ALL ? array(T_OBJ_RACE => $sel_race) : array();
     $filter_having = array('having' => array($sel_ff_field . ($sel_ff_ineq == self::T_NS__ffilter_ineq_gt ? '>=' : '<=') . $sel_ff_limit));
     if ($_COACH_TEAM_LIST && $sel_state != T_STATE_ALLTIME) {
         $filter_having['having'][] = 'rdy IS TRUE';
         $filter_having['having'][] = 'retired IS FALSE';
     }
     $SGRP_GEN = $sel_sgrp == 'GENERAL';
     $ALL_TIME = self::_isNodeAllTime($obj, $sel_node, $sel_node_id);
     $manualSort = isset($_GET["sort{$opts['GET_SS']}"]);
     $sortRule = array_merge($manualSort ? array(($_GET["dir{$opts['GET_SS']}"] == 'a' ? '+' : '-') . $_GET["sort{$opts['GET_SS']}"]) : array(), $obj == T_OBJ_TEAM && $sel_node == T_NODE_TOURNAMENT && is_object($tr = new Tour($sel_node_id)) ? array_map(create_function('$val', 'return $val[0]."mv_".substr($val,1);'), $tr->getRSSortRule()) : sort_rule($obj));
     $set_avg = isset($_GET['pms']) && $_GET['pms'];
     // Per match stats?
     echo '<br><a href="' . $opts['url'] . '&amp;pms=' . ($set_avg ? 0 : 1) . '"><b>' . $lng->getTrn('common/' . ($set_avg ? 'ats' : 'pms')) . "</b></a><br><br>\n";
     // Common $obj type fields.
     $fields = self::_getDefFields($obj, $sel_node, $sel_node_id);
     // Was a different (non-general) stats group selected?
     if (!$SGRP_GEN) {
         $grps_short = getESGroups(true, true);
         $grps_long = getESGroups(true, false);
         $fields_short = $grps_short[$sel_sgrp];
         $fields_long = $grps_long[$sel_sgrp];
         $fields = array_combine(array_strpack('mv_%s', $fields_long), array_map(create_function('$f', 'return array("desc" => $f);'), $fields_short));
         $objFields_avg = array_merge($objFields_avg, array_map(create_function('$k', 'return substr($k, 3);'), array_keys($fields)));
     }
     switch ($obj) {
         case STATS_PLAYER:
             $tblTitle = $lng->getTrn('menu/statistics_menu/player_stn');
             $fields_before = array('name' => array('desc' => $lng->getTrn('common/player'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_PLAYER, false, false, false), 'field' => 'obj_id', 'value' => 'player_id')), 'f_tname' => array('desc' => $lng->getTrn('common/team'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'owned_by_team_id')));
             $PAGELENGTH = $settings['standings']['length_players'];
             list($objs, $PAGES) = Stats::getRaw(T_OBJ_PLAYER, $filter_node + $filter_having + $filter_race, array($PAGE, $PAGELENGTH), $sortRule, $set_avg);
             break;
         case STATS_TEAM:
             $tblTitle = $lng->getTrn('menu/statistics_menu/team_stn');
             $fields_before = array('name' => array('desc' => $lng->getTrn('common/name'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_TEAM, false, false, false), 'field' => 'obj_id', 'value' => 'team_id')));
             // Show teams standings list only for teams owned by... ?
             switch ($W_TEAMS_FROM ? $opts['teams_from'] : false) {
                 case T_OBJ_COACH:
                     $fields_before['f_rname'] = array('desc' => $lng->getTrn('common/race'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_RACE, false, false, false), 'field' => 'obj_id', 'value' => 'f_race_id'));
                     list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + $filter_race + array(T_OBJ_COACH => (int) $opts['teams_from_id']), false, $sortRule, $set_avg);
                     break;
                 case T_OBJ_RACE:
                     $fields_before['f_cname'] = array('desc' => $lng->getTrn('common/coach'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'owned_by_coach_id'));
                     $PAGELENGTH = $settings['standings']['length_teams'];
                     list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + array(T_OBJ_RACE => (int) $opts['teams_from_id']), array($PAGE, $PAGELENGTH), $sortRule, $set_avg);
                     break;
                     // All teams
                 // All teams
                 default:
                     $PAGELENGTH = $settings['standings']['length_teams'];
                     list($objs, $PAGES) = Stats::getRaw(T_OBJ_TEAM, $filter_node + $filter_having + $filter_race, array($PAGE, $PAGELENGTH), $sortRule, $set_avg);
             }
             // Translating race name
             foreach ($objs as &$o) {
                 $o['f_rname'] = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $o['f_rname'])));
             }
             break;
         case STATS_RACE:
             $tblTitle = $lng->getTrn('menu/statistics_menu/race_stn');
             $fields_before = array('name' => array('desc' => $lng->getTrn('common/race'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_RACE, false, false, false), 'field' => 'obj_id', 'value' => 'race_id')));
             $dash_empty = false;
             if ($sel_node == T_NODE_TOURNAMENT) {
                 $dash_empty = 'mv_team_cnt';
             } else {
                 if ($ALL_TIME) {
                     $dash_empty = 'rg_team_cnt';
                 }
             }
             if ($dash_empty) {
                 $extra['dashed'] = array('condField' => $dash_empty, 'fieldVal' => 0, 'noDashFields' => array('name'));
             }
             list($objs, $PAGES) = Stats::getRaw(T_OBJ_RACE, $filter_node + $filter_having, false, $sortRule, $set_avg);
             // Translating race name
             foreach ($objs as &$o) {
                 $o['name'] = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $o['name'])));
             }
             break;
         case STATS_COACH:
             $tblTitle = $lng->getTrn('menu/statistics_menu/coach_stn');
             $fields_before = array('name' => array('desc' => $lng->getTrn('common/coach'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_COACH, false, false, false), 'field' => 'obj_id', 'value' => 'coach_id')));
             $PAGELENGTH = $settings['standings']['length_coaches'];
             list($objs, $PAGES) = Stats::getRaw(T_OBJ_COACH, $filter_node + $filter_having, array($PAGE, $PAGELENGTH), $sortRule, $set_avg);
             break;
         case STATS_STAR:
             $tblTitle = $lng->getTrn('menu/statistics_menu/star_stn');
             $fields_before = array('name' => array('desc' => $lng->getTrn('common/star'), 'href' => array('link' => urlcompile(T_URL_PROFILE, T_OBJ_STAR, false, false, false), 'field' => 'obj_id', 'value' => 'star_id')), 'cost' => array('desc' => 'Price', 'kilo' => true, 'suffix' => 'k'), 'ma' => array('desc' => 'Ma'), 'st' => array('desc' => 'St'), 'ag' => array('desc' => 'Ag'), 'av' => array('desc' => 'Av'));
             $extra['dashed'] = array('condField' => 'mv_played', 'fieldVal' => 0, 'noDashFields' => array('name'));
             list($objs, $PAGES) = Stats::getRaw(T_OBJ_STAR, $filter_node + $filter_having, false, $sortRule, $set_avg);
             break;
     }
     foreach ($objs as $idx => $obj) {
         $objs[$idx] = (object) $obj;
     }
     if (!$SGRP_GEN) {
         $tmp = $fields_before['name'];
         $fields_before = $fields_after = array();
         $fields_before['name'] = $tmp;
     }
     $fields = array_merge($fields_before, $fields, $fields_after);
     // Add average marker on fields (*).
     if ($set_avg) {
         foreach (array_keys($fields) as $f) {
             $f_cut = preg_replace('/^\\w\\w\\_/', '', $f);
             if (in_array($f_cut, $objFields_avg)) {
                 $fields[$f]['desc'] .= '*';
             }
         }
     }
     $extra['page'] = $PAGE;
     $extra['pages'] = $PAGES;
     $extra['pagelength'] = $PAGELENGTH;
     HTMLOUT::sort_table($tblTitle, $opts['url'] . ($set_avg ? '&amp;pms=1' : ''), $objs, $fields, $sortRule, array(), $extra);
     return array_key_exists('return_objects', $opts) && $opts['return_objects'] ? array($objs, $sortRule) : true;
 }
コード例 #7
0
ファイル: class_memmatches.php プロジェクト: nicholasmr/obblm
    public static function main($argv)
    {
        global $lng;
        title($lng->getTrn('name', __CLASS__));
        echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n";
        list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array());
        echo "<br>";
        $_rows = 0;
        foreach (self::getMemMatches($sel_node, $sel_node_id) as $d => $matches) {
            $_container_style = 'float:left; width:50%;';
            if ($_rows == 0) {
                echo "<div style='{$_container_style}'>";
            }
            ?>
        <div class="boxWide">
            <div class="boxTitle<?php 
            echo T_HTMLBOX_INFO;
            ?>
"><?php 
            echo $lng->getTrn($d, __CLASS__);
            ?>
</div>
            <div class="boxBody">
                <table class="common">
                <?php 
            if (empty($matches)) {
                ?>
<tr><td align="center"><br><br><?php 
                echo preg_replace('/\\sX\\s/', ' ' . MAX_MEM_MATCHES . ' ', $lng->getTrn('filled', __CLASS__));
                ?>
<br><br></td></tr><?php 
            } else {
                $i = count($matches);
                foreach ($matches as $m) {
                    $t1 = new Team($m->team1_id);
                    $t2 = new Team($m->team2_id);
                    $img1 = new ImageSubSys(IMGTYPE_TEAMLOGO, $t1->team_id);
                    $img2 = new ImageSubSys(IMGTYPE_TEAMLOGO, $t2->team_id);
                    ?>
                    <tr>
                        <td align="left" style="width:40%;"><img border='0px' height='30' width='30' alt='team picture' src='<?php 
                    echo $img1->getPath();
                    ?>
'><?php 
                    echo $t1->name;
                    ?>
</td>
                        <td align="center">
                        <?php 
                    switch ($d) {
                        case 'td':
                        case 'cp':
                        case 'intcpt':
                        case 'ki':
                        case 'cas':
                            $v = array();
                            $s = $d == 'cas' ? 'bh+ki+si' : $d;
                            foreach (array(1, 2) as $j) {
                                $query = "SELECT SUM({$s}) as '{$s}' FROM matches, match_data WHERE f_match_id = match_id AND match_id = {$m->match_id} AND f_team_id = team{$j}_id";
                                $result = mysql_query($query);
                                $row = mysql_fetch_assoc($result);
                                $v[$j] = $row[$s] ? $row[$s] : 0;
                            }
                            echo "<b>{$v['1']} &nbsp;-&nbsp; {$v['2']}</b>";
                            break;
                        case 'svic':
                            echo "<b>{$m->team1_score} &nbsp;-&nbsp; {$m->team2_score}</b>";
                            break;
                        case 'inc':
                            echo '<b>' . $m->income1 / 1000 . 'k - ' . $m->income2 / 1000 . 'k</b>';
                            break;
                        case 'gate':
                            echo '<b>' . $m->gate / 1000 . 'k</b>';
                            break;
                        case 'mfans':
                            echo "<b>{$m->fans}</b>";
                            break;
                        case 'tvdiff':
                            echo '<b>' . $m->tv1 / 1000 . 'k - ' . $m->tv2 / 1000 . 'k</b>';
                            break;
                    }
                    ?>
                        </td>
                        <td align="right" style="width:40%;"><?php 
                    echo $t2->name;
                    ?>
<img border='0px' height='30' width='30' alt='team picture' src='<?php 
                    echo $img2->getPath();
                    ?>
'></td>
                    </tr>
                    <tr>
                        <td align="right" colspan="3">
                        <small>
                        <i><?php 
                    echo get_alt_col('tours', 'tour_id', $m->f_tour_id, 'name');
                    ?>
, <?php 
                    echo textdate($m->date_played, true);
                    ?>
</i>,
                        <a href="index.php?section=matches&amp;type=report&amp;mid=<?php 
                    echo $m->match_id;
                    ?>
"><?php 
                    echo $lng->getTrn('common/view');
                    ?>
</a>
                        </small>
                        </td>
                    </tr>
                    <?php 
                    if (--$i > 0) {
                        echo '<tr><td colspan="3"><hr></td></tr>';
                    }
                }
            }
            ?>
                </table>
            </div>
        </div>
        <?php 
            if (is_int(($_rows + 1) / MMATCHES_BREAK)) {
                echo "</div>";
                echo "<div style='{$_container_style}'>";
            }
            $_rows++;
        }
        echo "</div>";
    }