/** * Create a list of events * * @param integer $range Range indicator (upcoming, past, etc) * @param integer $category Category to limit search * @param string $block_title Title of block * @return string HTML for list page */ function EVLIST_listview($range = '', $category = '', $calendar = '', $block_title = '') { global $_CONF, $_EV_CONF, $_USER, $_TABLES, $LANG_EVLIST; EVLIST_setViewSession('list', $year, $month, $day); $retval = ''; $T = new Template(EVLIST_PI_PATH . '/templates/'); $T->set_file('index', 'index.thtml'); if ($_EV_CONF['_can_add']) { $add_event_link = EVLIST_URL . '/event.php?edit=x'; } else { $add_event_link = ''; } $T->set_var(array('action' => EVLIST_URL . '/index.php', 'range_options' => EVLIST_GetOptions($LANG_EVLIST['ranges'], $range), 'add_event_link' => $add_event_link, 'add_event_text' => $LANG_EVLIST['add_event'], 'rangetext' => $LANG_EVLIST['ranges'][$range])); $page = empty($_GET['page']) ? 1 : (int) $_GET['page']; $opts = array('cat' => $category, 'page' => $page, 'limit' => $_EV_CONF['limit_list'], 'cal' => $calendar); switch ($range) { case 1: // past $start = EV_MIN_DATE; $end = $_EV_CONF['_today']; $opts['order'] = 'DESC'; break; case 3: //this week $start = $_EV_CONF['_today']; $end = date('Y-m-d', strtotime('+1 week', $_EV_CONF['_today_ts'])); break; case 4: //this month $start = $_EV_CONF['_today']; $end = date('Y-m-d', strtotime('+1 month', $_EV_CONF['_today_ts'])); break; case 2: //upcoming //upcoming default: $start = $_EV_CONF['_today']; $end = EV_MAX_DATE; break; } $events = EVLIST_getEvents($start, $end, $opts); if (empty($events)) { //return empty list msg $T->set_var(array('title' => '', 'block_title' => $block_title, 'empty_listmsg' => $LANG_EVLIST['no_match'])); if (!empty($range)) { $andrange = '&range=' . $range; $T->set_var('range', $range); } else { $andrange = '&range=2'; } if (!empty($category)) { $andcat = '&cat=' . $category; $T->set_var('category', $category); } else { $andcat = ''; } } else { //populate list // So we don't call SEC_hasRights inside the loop $isAdmin = SEC_hasRights('evlist.admin'); $T->set_file(array('item' => 'list_item.thtml', 'editlinks' => 'edit_links.thtml', 'category_form' => 'category_dd.thtml')); if (!empty($range)) { $andrange = '&range=' . $range; $T->set_var('range', $range); } else { $andrange = '&range=2'; } if (!empty($category)) { $andcat = '&cat=' . $category; $T->set_var('category', $category); } else { $andcat = ''; } // Track events that have been shown so we show them only once. $already_shown = array(); foreach ($events as $date => $daydata) { foreach ($daydata as $A) { if (array_key_exists($A['rp_id'], $already_shown)) { continue; } else { $already_shown[$A['rp_id']] = 1; } $titlelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat); $titlelink = '<a href="' . $titlelink . '">' . COM_stripslashes($A['title']) . '</a>'; $summary = PLG_replaceTags(COM_stripslashes($A['summary'])); $datesummary = sprintf($LANG_EVLIST['event_begins'], EVLIST_formattedDate(strtotime($A['rp_date_start']))); $morelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat); $morelink = '<a href="' . $morelink . '">' . $LANG_EVLIST['read_more'] . '</a>'; if (empty($A['email'])) { $contactlink = $_CONF['site_url'] . '/profiles.php?uid=' . $A['owner_id']; } else { $contactlink = 'mailto:' . EVLIST_obfuscate($A['email']); } $contactlink = '<a href="' . $contactlink . '">' . $LANG_EVLIST['ev_contact'] . '</a>'; $T->set_var(array('title' => $titlelink, 'date_summary' => $datesummary, 'summary' => $summary, 'more_link' => $morelink, 'contact_link' => $contactlink, 'contact_name' => $A['contact'], 'owner_name' => COM_getDisplayName($A['owner_id']), 'block_title' => $block_title, 'category_links' => EVLIST_getCatLinks($A['ev_id'], $andrange), 'cal_id' => $A['cal_id'], 'cal_name' => $A['cal_name'], 'cal_fgcolor' => $A['fgcolor'], 'cal_bgcolor' => $A['bgcolor'])); $T->parse('event_item', 'item', true); } } } $T->parse('output', 'index'); $retval .= $T->finish($T->get_var('output')); // Set page navigation $retval .= EVLIST_pagenav($start, $end, $category, $page, $range, $calendar); return $retval; }
/** * Display a small monthly calendar for the current month. * Dates that have events scheduled are highlighted. * * @param integer $year Year to display, default is current year * @param integer $month Starting month * @return string HTML for calendar page */ function EVLIST_smallmonth($year = 0, $month = 0, $opts = array()) { global $_CONF, $_EV_CONF, $LANG_MONTH, $_SYSTEM; $retval = ''; // Default to the current year if ($year == 0) { $year = date('Y'); } if ($month == 0) { $month = date('m'); } $monthnum_str = sprintf("%02d", (int) $month); // Get all the dates in the period $starting_date = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year)); $ending_date = date('Y-m-d', mktime(23, 59, 59, $month, 31, $year)); $calendarView = Date_Calc::getCalendarMonth($month, $year, '%Y-%m-%d'); $events = EVLIST_getEvents($starting_date, $ending_date, $opts); $T = new Template(EVLIST_PI_PATH . '/templates'); $T->set_file(array('smallmonth' => 'phpblock_month.thtml')); $T->set_var('thisyear', $year); $T->set_var('month', $month); $T->set_var('monthname', $LANG_MONTH[(int) $month]); // Set each day column header to the first letter of the day name $T->set_block('smallmonth', 'daynames', 'nBlock'); $daynames = EVLIST_getDayNames(1); foreach ($daynames as $key => $dayname) { $T->set_var('dayname', $dayname); $T->parse('nBlock', 'daynames', true); } $T->set_block('smallmonth', 'week', 'wBlock'); USES_class_date(); $dt = new Date('now', $_CONF['timezone']); foreach ($calendarView as $weeknum => $weekdata) { list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]); $T->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay)); $T->set_block('smallmonth', 'day', 'dBlock'); foreach ($weekdata as $daynum => $daydata) { list($y, $m, $d) = explode('-', $daydata); $T->clear_var('no_day_link'); if ($daydata == $_EV_CONF['_today']) { $dayclass = 'monthtoday'; } elseif ($m == $monthnum_str) { $dayclass = 'monthon'; } else { $T->set_var('no_day_link', 'true'); $dayclass = 'monthoff'; } $popup = ''; if (isset($events[$daydata])) { // Create the tooltip hover text $daylinkclass = $dayclass == 'monthoff' ? 'nolink-events' : 'day-events'; foreach ($events[$daydata] as $event) { // Show event titles on different lines if more than one if (!empty($popup)) { $popup .= EVLIST_tooltip_newline(); } // Don't show a time for all-day events if ($event['allday'] == 0 && $event['rp_date_start'] == $event['rp_date_end']) { $dt->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start1'])); // Time is a localized string, not a timestamp, so // don't adjust for the timezone $popup .= $dt->format($_CONF['timeonly'], false) . ': '; } $popup .= htmlentities($event['title']); } $T->set_var('popup', $popup); } else { $daylinkclass = 'day-noevents'; $T->clear_var('popup'); } $T->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL)); $T->parse('dBlock', 'day', true); } $T->parse('wBlock', 'week', true); $T->clear_var('dBlock'); } $T->parse('output', 'smallmonth'); return $T->finish($T->get_var('output')); }
/** Include core glFusion libraries */ require_once '../lib-common.php'; // Set up the period to export- now + 1 year $start = $_EV_CONF['_today']; list($y, $m, $d) = explode('-', $start); $end = date('Y-m-d', mktime(0, 0, 0, $m, $d, $y + 1)); $opts = array('ical' => 1); if (isset($_GET['cal']) && !empty($_GET['cal'])) { // Get only a specific calendar $opts['cal'] = (int) $_GET['cal']; } if (isset($_GET['rp_id']) && !empty($_GET['rp_id'])) { // Get a single event $opts['rp_id'] = (int) $_GET['rp_id']; } $events = EVLIST_getEvents($start, $end, $opts); $ical = ''; $space = ' '; $rp_shown = array(); foreach ($events as $day) { foreach ($day as $event) { // Check if this repeat is already shown. We only want multi-day // events included once instead of each day if (array_key_exists($event['rp_id'], $rp_shown)) { continue; } $rp_shown[$event['rp_id']] = 1; $start_time = gmstrftime('%Y%m%dT%H%M%SZ', strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start1'])); $end_time = gmstrftime('%Y%m%dT%H%M%SZ', strtotime($event['rp_date_end'] . ' ' . $event['rp_time_end1'])); $summary = $event['title']; $permalink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $event['rp_id']);