Example #1
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();
    }