コード例 #1
0
ファイル: evlist_views.inc.php プロジェクト: matrox66/evlist
/**
*   Display a yearly calendar.
*   Dates that have events scheduled are highlighted.
*
*   @param  integer $year   Year to display, default is current year
*   @param  integer $month  Starting month
*   @param  integer $day    Starting day
*   @param  integer $cat    Category to show
*   @param  integer $cal    Calendar to show
*   @return string          HTML for calendar page
*/
function EVLIST_yearview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '')
{
    global $_CONF, $_EV_CONF, $LANG_MONTH;
    EVLIST_setViewSession('year', $year, $month, $day);
    $retval = '';
    // Default to the current year
    if ($year == 0) {
        $year = date('Y');
    }
    if ($month == 0) {
        $month = date('m');
    }
    if ($day == 0) {
        $day = date('d');
    }
    $cat = (int) $cat;
    $cal = (int) $cal;
    // Get all the dates in the year
    $starting_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year));
    $ending_date = date('Y-m-d', mktime(0, 0, 0, 1, 1, $year + 1));
    $calendarView = Date_Calc::getCalendarYear($year, '%Y-%m-%d');
    $daynames = EVLIST_getDayNames(1);
    $events = EVLIST_getEvents($starting_date, $ending_date, array('cat' => $cat, 'cal' => $cal));
    $T = new Template(EVLIST_PI_PATH . '/templates/yearview');
    $tpl = 'yearview';
    if ($opt == 'print') {
        $tpl .= '_print';
    } elseif ($_EV_CONF['cal_tmpl'] == 'json') {
        $tpl .= '_json';
    }
    $T->set_file(array('yearview' => $tpl . '.thtml'));
    $count = 0;
    $T->set_block('yearview', 'month', 'mBlock');
    foreach ($calendarView as $monthnum => $monthdata) {
        $monthnum_str = sprintf("%02d", $monthnum + 1);
        $count++;
        if (($count - 1) % 4 == 0) {
            $T->set_var('st_row', 'true');
        } else {
            $T->clear_var('st_row');
        }
        $M = new Template($_CONF['path'] . 'plugins/evlist/templates/yearview');
        $M->set_file(array('smallmonth' => 'smallmonth.thtml'));
        $M->set_var('thisyear', $year);
        $M->set_var('month', $monthnum + 1);
        $M->set_var('monthname', $LANG_MONTH[$monthnum + 1]);
        $M->set_block('smallmonth', 'daynames', 'nBlock');
        for ($i = 0; $i < 7; $i++) {
            $M->set_var('dayname', $daynames[$i]);
            $M->parse('nBlock', 'daynames', true);
        }
        $M->set_block('smallmonth', 'week', 'wBlock');
        foreach ($monthdata as $weeknum => $weekdata) {
            list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]);
            $M->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal));
            $M->set_block('smallmonth', 'day', 'dBlock');
            foreach ($weekdata as $daynum => $daydata) {
                list($y, $m, $d) = explode('-', $daydata);
                $M->clear_var('no_day_link');
                if ($daydata == $_EV_CONF['_today']) {
                    $dayclass = 'today';
                } elseif ($m == $monthnum_str) {
                    $dayclass = 'on';
                } else {
                    $M->set_var('no_day_link', 'true');
                    $dayclass = 'off';
                }
                if (isset($events[$daydata])) {
                    // Create the mootip hover text
                    $popup = '';
                    $daylinkclass = $dayclass == 'off' ? 'nolink-events' : 'day-events';
                    foreach ($events[$daydata] as $event) {
                        // Separate events by a line (if more than one)
                        if (!empty($popup)) {
                            $popup .= '<hr />' . LB;
                        }
                        // Don't show a time for all-day events
                        if ($event['allday'] == 0) {
                            $popup .= date($_CONF['timeonly'], strtotime($event['date_start'] . ' ' . $event['time_start1'])) . ': ';
                        }
                        $popup .= htmlentities($event['title']);
                    }
                    $M->set_var('popup', $popup);
                } else {
                    $daylinkclass = 'day-noevents';
                    $M->clear_var('popup');
                }
                $M->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal));
                $M->parse('dBlock', 'day', true);
            }
            $M->parse('wBlock', 'week', true);
            $M->clear_var('dBlock');
        }
        $M->parse('onemonth', 'smallmonth');
        $T->set_var('month', $M->finish($M->get_var('onemonth')));
        if ($count % 4 == 0) {
            $T->set_var('end_row', 'true');
        } else {
            $T->clear_var('end_row');
        }
        $T->parse('mBlock', 'month', true);
    }
    $T->set_var(array('pi_url' => EVLIST_URL, 'thisyear' => $year, 'prevyear' => $year - 1, 'nextyear' => $year + 1, 'cal_header' => EVLIST_calHeader($year, $month, $day, 'year', $cat, $cal), 'cal_footer' => EVLIST_calFooter($calendars_used), 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal));
    $T->parse('output', 'yearview');
    return $T->finish($T->get_var('output'));
}
コード例 #2
0
ファイル: event.php プロジェクト: matrox66/evlist
            // Default action, view the calendar or event
            COM_setArgNames(array('eid', 'ts', 'range', 'cat'));
            $eid = COM_sanitizeID(COM_getArgument('eid'), false);
        }
        if (!empty($eid)) {
            USES_evlist_class_repeat();
            $Rep = new evRepeat($eid);
            $pagetitle = COM_stripslashes($Rep->Event->title);
            if ($view == 'print') {
                $template = 'event_print';
                $query = '';
            }
            $query = isset($_GET['query']) ? $_GET['query'] : '';
            $content .= $Rep->Detail('', $query, $template);
        } else {
            // Shouldn't be in this file without an event ID to display or edit
            echo COM_refresh(EVLIST_URL . '/index.php');
            exit;
        }
        break;
}
$display = EVLIST_siteHeader($pagetitle);
$display .= EVLIST_calHeader(date('Y'), date('m'), date('d'), 'detail', $cat_id, $cal_id);
if (!empty($msg)) {
    $display .= COM_startBlock($LANG_EVLIST['alert'], '', 'blockheader-message.thtml');
    $display .= $LANG_EVLIST['messages'][$msg];
    $display .= COM_endBlock('blockfooter-message.thtml');
}
$display .= $content;
$display .= EVLIST_siteFooter();
echo $display;
コード例 #3
0
ファイル: index.php プロジェクト: matrox66/evlist
                break;
            case 4:
                // Next 1 month
                $block_title = $LANG_EVLIST['this_month_events'];
                break;
            default:
                // Upcoming events
                $range = 2;
            case 2:
                $block_title = $LANG_EVLIST['upcoming_events'];
                break;
        }
        if (!empty($category)) {
            $block_title .= '&nbsp;/&nbsp;' . $LANG_EVLIST['category'] . ':&nbsp;' . $catname;
        }
        $content .= EVLIST_calHeader($year, $month, $day, 'list', $category, $calendar, $range);
        $content .= EVLIST_listview($range, $category, $calendar, $block_title);
        break;
    default:
        $content = EVLIST_view('', 0, 0, 0);
        break;
}
$display = EVLIST_siteHeader($LANG_EVLIST['pi_name']);
if (!empty($msg)) {
    //msg block
    $display .= COM_startBlock('', '', 'blockheader-message.thtml');
    $display .= $LANG_EVLIST['messages'][$msg];
    $display .= COM_endBlock('blockfooter-message.thtml');
}
$display .= $content;
$display .= EVLIST_siteFooter();