Exemplo n.º 1
0
/**
 * Loads up the specified theme for usage
 * @param string $theme Theme 'folder' name to be loaded
 * @return array Array containing the theme's .info data
 */
function theme_get_info($theme = null)
{
    global $ssc_site_path, $ssc_site_url;
    static $info = null;
    if ($theme) {
        // Get the theme data
        $info = ssc_parse_ini_file('theme', "{$ssc_site_path}/themes/{$theme}/{$theme}.info");
        if (!$info) {
            ssc_die(array('title' => 'Invalid Theme', 'body' => 'The selected theme is borked'));
        }
        if (isset($info['js']) && is_array($info['js'])) {
            foreach ($info['js'] as $path) {
                ssc_add_js("/themes/{$theme}/{$path}");
            }
        }
        if (isset($info['css']) && is_array($info['css'])) {
            foreach ($info['css'] as $path) {
                $tmp = explode("#", $path);
                ssc_add_css("/themes/{$theme}/{$tmp['0']}", $tmp[1]);
            }
        }
    }
    return $info;
}
Exemplo n.º 2
0
/**
 * Implementation of module_content()
 * 
 * Results content.  At this stage, no arguments so present results for entire regatta. Bracket refers to mouse-over
 * 
 *   - /
 *     No parameters.  Should show abbr'd |sail|class|name|skip (crew)|place(corr. time)[|place(corr. time)...]
 * 
 *   - /heat/<num>   or    /heat-<num
 *     Show detailed version for a heat perhaps?  Probably not feasable.
 */
function sailing_content()
{
    global $ssc_database;
    ssc_add_js('/modules/sailing/sailing.js');
    // See if results exist
    $result = $ssc_database->query("SELECT name, description, updated, flags, heats FROM #__sailing_series WHERE id = %d LIMIT 1", $_GET['path-id']);
    if (!($result && ($data = $ssc_database->fetch_assoc($result)))) {
        ssc_not_found();
        return;
    }
    // Set up some flags
    $flags = $data['flags'];
    $prefix = $flags & SSC_SAILING_PREFIX ? "Division " : "";
    $show_class = ($flags & SSC_SAILING_CLASS) > 0;
    $show_club = ($flags & SSC_SAILING_CLUB) > 0;
    // Heat numbers
    $heats = explode(",", $data['heats']);
    // Description / title
    ssc_set_title($data['name']);
    $out = "";
    if (strlen($data['description']) > 0) {
        if (!ssc_load_library('sscText')) {
            $out .= check_plain($data['description']);
        } else {
            $out .= sscText::convert($data['description']);
        }
    }
    // Prepare for table
    $result = $ssc_database->query("SELECT r.results, r.times, r.points, r.division, e.number, e.skipper, e.crew, e.name AS boatname, e.class, e.club FROM #__sailing_results r LEFT JOIN #__sailing_entries e ON e.id = r.uid WHERE r.series_id = %d ORDER BY r.division ASC, r.points ASC", $_GET['path-id']);
    if (!$result || $ssc_database->number_rows() < 1) {
        // Empty or sql failure
        $out .= "There are no race results available for this series yet";
        return $out;
    } else {
        // Start outputting
        $out .= '<table class="sail-table" summary="Race results">';
        $col_header = _ssc_sailing_table_header($flags, $heats, $col_count);
        // Loop through results
        $div = '-1';
        while ($data = $ssc_database->fetch_assoc($result)) {
            // Re-echo headers for each division
            if ($div != $data['division']) {
                if ($div == '-1') {
                    $out .= "<thead><tr><th class=\"div-heading\" colspan=\"{$col_count['total']}\">{$prefix}{$data['division']}</th></tr>";
                    $out .= "{$col_header}</thead><tbody>";
                } else {
                    $out .= '<tr><th class="div-heading" colspan="' . $col_count['total'] . '">' . $prefix . $data['division'] . '</th></tr>';
                    $out .= $col_header;
                }
                $div = $data['division'];
            }
            // Row contents
            $out .= "<tr><td>{$data['number']}</td>" . ($show_class ? "<td>{$data['class']}</td>" : '') . "<td>{$data['boatname']}</td>";
            if ($data['crew'] != '') {
                $out .= "<td><span title=\"{$data['crew']}\">{$data['skipper']}</span></td>";
            } else {
                $out .= "<td>{$data['skipper']}</td>";
            }
            if ($show_club) {
                $out .= "<td>{$data['club']}</td>";
            }
            // Parse results
            $heats = explode(",", $data['results']);
            $times = explode(",", $data['times']);
            for ($i = 0; $i < $col_count['heats']; $i++) {
                if ($times[$i] != '') {
                    if ((double) $times[$i] > 0) {
                        $out .= '<td><span title="' . sprintf("%1.1f", (double) $times[$i]) . " min\">{$heats[$i]}</span></td>";
                    } else {
                        $out .= "<td><span title=\"{$times[$i]}\">{$heats[$i]}</span></td>";
                    }
                } else {
                    $out .= "<td>{$heats[$i]}</td>";
                }
            }
            $out .= '</tr>';
        }
        // Tidy up
        $out .= '</tbody></table>';
    }
    return $out;
}
Exemplo n.º 3
0
/**
 * Start the display of the page by booting up the theme
 */
function ssc_frontend_init()
{
    global $SSC_SETTINGS, $ssc_site_path, $ssc_database;
    // Include the language file
    $file = "{$ssc_site_path}/lang/" . $SSC_SETTINGS['lang']['tag'] . ".inc.php";
    if (file_exists($file)) {
        require_once $file;
    } else {
        ssc_die(array('title' => 'Bad language', 'body' => "Language '" . $SSC_SETTINGS['lang']['tag'] . "' is currently not installed"));
    }
    // Set up the theme
    require_once "{$ssc_site_path}/includes/core.theme.inc.php";
    $theme = ssc_var_get('theme_default', SSC_DEFAULT_THEME);
    $file = "{$ssc_site_path}/themes/{$theme}/{$theme}.";
    if (!file_exists($file . 'theme.php') && !file_exists($file . 'info')) {
        ssc_die(array('title' => 'Bad theme', 'body' => 'Specified theme ' . $theme . ' is not installed'));
    }
    theme_get_info($theme);
    ssc_add_js("/includes/core.js");
}