function get_program_list_from_gdoc($source_url)
{
    $handle = @fopen($source_url, 'r');
    if (!$handle) {
        return FALSE;
        // failed
    }
    $program_list = array();
    while (($PROG = fgetcsv($handle)) !== FALSE) {
        $program = make_program($PROG);
        if (!validate_program_data($program)) {
            continue;
        }
        // use strtotime to convert to unix timestamp.
        $program['from'] = strtotime($program['from']);
        $program['to'] = strtotime($program['to']);
        // empty string or NULL will get 0
        $program['room'] = intval($program['room']);
        $program['type'] = intval($program['type']);
        $program['community'] = intval($program['community']);
        if (isset($program['bio'])) {
            $program['bio'] = Markdown_Without_Markup(linkify($program['bio']));
        }
        if (isset($program['abstract'])) {
            $program['abstract'] = Markdown_Without_Markup(linkify($program['abstract']));
        }
        if (isset($program['youtube'])) {
            $videos = array();
            foreach (explode("\n", $program['youtube']) as $url) {
                if (trim($url)) {
                    $videos[] = preg_replace('/^.+v=([^"&?\\/ ]{11}).*$/', '$1', trim($url));
                    // only get the ID
                }
            }
            $program['youtube'] = $videos;
        }
        // setting room = -1 and leaving speaker empty indicate a break session
        $program['isBreak'] = $program['room'] < 0 && !isset($program['speaker']) ? true : false;
        $program_list[] = $program;
    }
    fclose($handle);
    return $program_list;
}
예제 #2
0
function fresh_program()
{
    $vs = get_stations();
    $stations = $vs["stations"];
    echo make_program("new", 1, $stations);
}