本文整理汇总了PHP中calendar_format_event_time函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_format_event_time函数的具体用法?PHP calendar_format_event_time怎么用?PHP calendar_format_event_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_format_event_time函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calendar_get_upcoming
function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime = 0)
{
global $CFG, $COURSE;
$display = new stdClass();
$display->range = $daysinfuture;
// How many days in the future we 'll look
$display->maxevents = $maxevents;
$output = array();
// Prepare "course caching", since it may save us a lot of queries
$coursecache = array();
$processed = 0;
$now = time();
// We 'll need this later
$usermidnighttoday = usergetmidnight($now);
if ($fromtime) {
$display->tstart = $fromtime;
} else {
$display->tstart = $usermidnighttoday;
}
// This works correctly with respect to the user's DST, but it is accurate
// only because $fromtime is always the exact midnight of some day!
$display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
// Get the events matching our criteria
$events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
// arguments to this function.
$morehref = '';
if (!empty($courses)) {
$courses = array_diff($courses, array(SITEID));
if (count($courses) == 1) {
$morehref = '&course=' . reset($courses);
}
}
if ($events !== false) {
$modinfo =& get_fast_modinfo($COURSE);
foreach ($events as $event) {
if (!empty($event->modulename)) {
if ($event->courseid == $COURSE->id) {
if (isset($modinfo->instances[$event->modulename][$event->instance])) {
$cm = $modinfo->instances[$event->modulename][$event->instance];
if (!$cm->uservisible) {
continue;
}
}
} else {
if (!($cm = get_coursemodule_from_instance($event->modulename, $event->instance))) {
continue;
}
if (!coursemodule_visible_for_user($cm)) {
continue;
}
}
if ($event->modulename == 'assignment') {
// TODO: rewrite this hack somehow
if (!calendar_edit_event_allowed($event)) {
// cannot manage entries, eg. student
if (!($assignment = get_record('assignment', 'id', $event->instance))) {
// error("assignment ID was incorrect");
continue;
}
// assign assignment to assignment object to use hidden_is_hidden method
require_once $CFG->dirroot . '/mod/assignment/lib.php';
if (!file_exists($CFG->dirroot . '/mod/assignment/type/' . $assignment->assignmenttype . '/assignment.class.php')) {
continue;
}
require_once $CFG->dirroot . '/mod/assignment/type/' . $assignment->assignmenttype . '/assignment.class.php';
$assignmentclass = 'assignment_' . $assignment->assignmenttype;
$assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm);
if ($assignmentinstance->description_is_hidden()) {
//force not to show description before availability
$event->description = get_string('notavailableyet', 'assignment');
}
}
}
}
if ($processed >= $display->maxevents) {
break;
}
$event->time = calendar_format_event_time($event, $now, $morehref);
$output[] = $event;
++$processed;
}
}
return $output;
}
示例2: calendar_get_upcoming
/**
* Gets the calendar upcoming event
*
* @param array $courses array of courses
* @param array|int|bool $groups array of groups, group id or boolean for all/no group events
* @param array|int|bool $users array of users, user id or boolean for all/no user events
* @param int $daysinfuture number of days in the future we 'll look
* @param int $maxevents maximum number of events
* @param int $fromtime start time
* @return array $output array of upcoming events
*/
function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime = 0)
{
global $CFG, $COURSE, $DB;
$display = new stdClass();
$display->range = $daysinfuture;
// How many days in the future we 'll look
$display->maxevents = $maxevents;
$output = array();
// Prepare "course caching", since it may save us a lot of queries
$coursecache = array();
$processed = 0;
$now = time();
// We 'll need this later
$usermidnighttoday = usergetmidnight($now);
if ($fromtime) {
$display->tstart = $fromtime;
} else {
$display->tstart = $usermidnighttoday;
}
// This works correctly with respect to the user's DST, but it is accurate
// only because $fromtime is always the exact midnight of some day!
$display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
// Get the events matching our criteria
$events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
// arguments to this function.
$hrefparams = array();
if (!empty($courses)) {
$courses = array_diff($courses, array(SITEID));
if (count($courses) == 1) {
$hrefparams['course'] = reset($courses);
}
}
if ($events !== false) {
$modinfo = get_fast_modinfo($COURSE);
foreach ($events as $event) {
if (!empty($event->modulename)) {
if ($event->courseid == $COURSE->id) {
if (isset($modinfo->instances[$event->modulename][$event->instance])) {
$cm = $modinfo->instances[$event->modulename][$event->instance];
if (!$cm->uservisible) {
continue;
}
}
} else {
if (!($cm = get_coursemodule_from_instance($event->modulename, $event->instance))) {
continue;
}
if (!\core_availability\info_module::is_user_visible($cm, 0, false)) {
continue;
}
}
}
if ($processed >= $display->maxevents) {
break;
}
$event->time = calendar_format_event_time($event, $now, $hrefparams);
$output[] = $event;
++$processed;
}
}
return $output;
}
示例3: show_day
/**
* Displays the calendar for a single day
*
* @param calendar_information $calendar
* @return string
*/
public function show_day(calendar_information $calendar, moodle_url $returnurl = null)
{
if ($returnurl === null) {
$returnurl = $this->page->url;
}
$events = calendar_get_upcoming($calendar->courses, $calendar->groups, $calendar->users, 1, 100, $calendar->timestamp_today());
$output = html_writer::start_tag('div', array('class' => 'header'));
$output .= $this->course_filter_selector($returnurl, get_string('dayviewfor', 'calendar'));
if (calendar_user_can_add_event($calendar->course)) {
$output .= $this->add_event_button($calendar->course->id, 0, 0, 0, $calendar->time);
}
$output .= html_writer::end_tag('div');
// Controls
$output .= html_writer::tag('div', calendar_top_controls('day', array('id' => $calendar->courseid, 'time' => $calendar->time)), array('class' => 'controls'));
if (empty($events)) {
// There is nothing to display today.
$output .= $this->output->heading(get_string('daywithnoevents', 'calendar'), 3);
} else {
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
$underway = array();
// First, print details about events that start today
foreach ($events as $event) {
$event = new calendar_event($event);
$event->calendarcourseid = $calendar->courseid;
if ($event->timestart >= $calendar->timestamp_today() && $event->timestart <= $calendar->timestamp_tomorrow() - 1) {
// Print it now
$event->time = calendar_format_event_time($event, time(), null, false, $calendar->timestamp_today());
$output .= $this->event($event);
} else {
// Save this for later
$underway[] = $event;
}
}
// Then, show a list of all events that just span this day
if (!empty($underway)) {
$output .= $this->output->heading(get_string('spanningevents', 'calendar'), 3);
foreach ($underway as $event) {
$event->time = calendar_format_event_time($event, time(), null, false, $calendar->timestamp_today());
$output .= $this->event($event);
}
}
$output .= html_writer::end_tag('div');
}
return $output;
}
示例4: get_record_sql
$d = $eventtime['mday'];
$y = $eventtime['year'];
if ($event->repeatid) {
$fetch = get_record_sql('SELECT 1, COUNT(id) AS repeatcount FROM ' . $CFG->prefix . 'event WHERE repeatid = ' . $event->repeatid);
$repeatcount = $fetch->repeatcount;
} else {
$repeatcount = 0;
}
// Display confirmation form
echo '<div class="header">' . get_string('deleteevent', 'calendar') . ': ' . $event->name . '</div>';
echo '<h2>' . get_string('confirmeventdelete', 'calendar') . '</h2>';
if ($repeatcount > 1) {
echo '<p>' . get_string('youcandeleteallrepeats', 'calendar', $repeatcount) . '</p>';
}
echo '<div class="eventlist">';
$event->time = calendar_format_event_time($event, time(), '', false);
calendar_print_event($event);
echo '</div>';
include 'event_delete.html';
}
break;
case 'edit':
if (empty($form)) {
$form->name = clean_text($event->name);
$form->courseid = $event->courseid;
// Not to update, but for date validation
$form->description = clean_text($event->description);
$form->timestart = $event->timestart;
$form->timeduration = $event->timeduration;
$form->id = $event->id;
$form->format = $defaultformat;
示例5: calendar_show_day
function calendar_show_day($d, $m, $y, $courses, $groups, $users, $courseid)
{
global $CFG, $USER;
if (!checkdate($m, $d, $y)) {
$now = usergetdate(time());
list($d, $m, $y) = array(intval($now['mday']), intval($now['mon']), intval($now['year']));
}
$getvars = 'from=day&cal_d=' . $d . '&cal_m=' . $m . '&cal_y=' . $y;
// For filtering
$starttime = make_timestamp($y, $m, $d);
$endtime = make_timestamp($y, $m, $d + 1) - 1;
$events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime);
$text = '';
if (!isguest() && !empty($USER->id) && calendar_user_can_add_event()) {
$text .= '<div class="buttons">';
$text .= '<form action="' . CALENDAR_URL . 'event.php" method="get">';
$text .= '<div>';
$text .= '<input type="hidden" name="action" value="new" />';
$text .= '<input type="hidden" name="course" value="' . $courseid . '" />';
$text .= '<input type="hidden" name="cal_d" value="' . $d . '" />';
$text .= '<input type="hidden" name="cal_m" value="' . $m . '" />';
$text .= '<input type="hidden" name="cal_y" value="' . $y . '" />';
$text .= '<input type="submit" value="' . get_string('newevent', 'calendar') . '" />';
$text .= '</div></form></div>';
}
$text .= get_string('dayview', 'calendar') . ': ' . calendar_course_filter_selector($getvars);
echo '<div class="header">' . $text . '</div>';
echo '<div class="controls">' . calendar_top_controls('day', array('id' => $courseid, 'd' => $d, 'm' => $m, 'y' => $y)) . '</div>';
if (empty($events)) {
// There is nothing to display today.
echo '<h3>' . get_string('daywithnoevents', 'calendar') . '</h3>';
} else {
echo '<div class="eventlist">';
$underway = array();
// First, print details about events that start today
foreach ($events as $event) {
$event->calendarcourseid = $courseid;
if ($event->timestart >= $starttime && $event->timestart <= $endtime) {
// Print it now
/*
$dayend = calendar_day_representation($event->timestart + $event->timeduration);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
$enddate = usergetdate($event->timestart + $event->timeduration);
// Set printable representation
echo calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).' ('.$timeend.')';
*/
//unset($event->time);
$event->time = calendar_format_event_time($event, time(), '', false, $starttime);
calendar_print_event($event);
} else {
// Save this for later
$underway[] = $event;
}
}
// Then, show a list of all events that just span this day
if (!empty($underway)) {
echo '<h3>' . get_string('spanningevents', 'calendar') . ':</h3>';
foreach ($underway as $event) {
$event->time = calendar_format_event_time($event, time(), '', false, $starttime);
calendar_print_event($event);
}
}
echo '</div>';
}
}
示例6: show_day
/**
* Displays the calendar for a single day
*
* @param calendar_information $calendar
* @return string
*/
public function show_day(calendar_information $calendar)
{
$calendar->checkdate();
$events = calendar_get_upcoming($calendar->courses, $calendar->groups, $calendar->users, 1, 100, $calendar->timestamp_today());
$output = html_writer::start_tag('div', array('class' => 'header'));
if (!isguestuser() && isloggedin() && calendar_user_can_add_event()) {
$output .= $this->add_event_button($calendar->courseid, $calendar->day, $calendar->month, $calendar->year);
}
//$output .= html_writer::tag('label', get_string('dayview', 'calendar'), array('for'=>'cal_course_flt_jump'));
$output .= $this->course_filter_selector(array('from' => 'day', 'cal_d' => $calendar->day, 'cal_m' => $calendar->month, 'cal_y' => $calendar->year), get_string('dayview', 'calendar'));
$output .= html_writer::end_tag('div');
// Controls
$output .= html_writer::tag('div', calendar_top_controls('day', array('id' => $calendar->courseid, 'd' => $calendar->day, 'm' => $calendar->month, 'y' => $calendar->year)), array('class' => 'controls'));
if (empty($events)) {
// There is nothing to display today.
$output .= $this->output->heading(get_string('daywithnoevents', 'calendar'), 3);
} else {
$output .= html_writer::start_tag('div', array('class' => 'eventlist'));
$underway = array();
// First, print details about events that start today
foreach ($events as $event) {
$event = new calendar_event($event);
$event->calendarcourseid = $calendar->courseid;
if ($event->timestart >= $calendar->timestamp_today() && $event->timestart <= $calendar->timestamp_tomorrow() - 1) {
// Print it now
$event->time = calendar_format_event_time($event, time(), null, false, $calendar->timestamp_today());
$output .= $this->event($event);
} else {
// Save this for later
$underway[] = $event;
}
}
// Then, show a list of all events that just span this day
if (!empty($underway)) {
$output .= $this->output->heading(get_string('spanningevents', 'calendar'), 3);
foreach ($underway as $event) {
$event->time = calendar_format_event_time($event, time(), null, false, $calendar->timestamp_today());
$output .= $this->event($event);
}
}
$output .= html_writer::end_tag('div');
}
return $output;
}
示例7: print_event
function print_event($ev, $param, $val, $allowededit)
{
echo '<tr>';
if ($allowededit) {
$imgedit = '<a href="event.php?' . $param . '=' . $val . '&action=edit&eventid=' . $ev->id . '"><img src="img/edit.gif" alt="edit" /></a>';
$imgdel = '<a href="event.php?' . $param . '=' . $val . '&action=delete&eventid=' . $ev->id . '"><img src="img/delete.gif" alt="delete" /></a>';
} else {
$imgedit = $imgdel = '';
}
$time = usergetdate($ev->timestart);
$timeend = usergetdate($ev->timestart + $ev->timeduration);
echo '<td style="text-align: left;">' . $imgedit . $imgdel;
$ev->time = calendar_format_event_time($ev, time(), '', false);
if (!empty($ev->time)) {
echo '<span class="date">' . $ev->time . '</span>';
} else {
echo '<span class="date">' . calendar_time_representation($ev->timestart) . '</span>';
}
echo '</td><td>' . $ev->location . '</td>';
echo '</tr>';
}
示例8: calendar_get_upcoming
function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime = 0)
{
global $CFG;
$display =& new stdClass();
$display->range = $daysinfuture;
// How many days in the future we 'll look
$display->maxevents = $maxevents;
$output = array();
// Prepare "course caching", since it may save us a lot of queries
$coursecache = array();
$processed = 0;
$now = time();
// We 'll need this later
$usermidnighttoday = usergetmidnight($now);
if ($fromtime) {
$display->tstart = $fromtime;
} else {
$display->tstart = $usermidnighttoday;
}
// This works correctly with respect to the user's DST, but it is accurate
// only because $fromtime is always the exact midnight of some day!
$display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
// Get the events matching our criteria
$whereclause = calendar_sql_where($display->tstart, $display->tend, $users, $groups, $courses);
if ($whereclause === false) {
$events = false;
} else {
$events = get_records_select('event', $whereclause, 'timestart');
}
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
// arguments to this function.
$morehref = '';
if (!empty($courses)) {
$courses = array_diff($courses, array(SITEID));
if (count($courses) == 1) {
$morehref = '&course=' . reset($courses);
}
}
if ($events !== false) {
foreach ($events as $event) {
if (!empty($event->modulename)) {
$mod = get_coursemodule_from_instance($event->modulename, $event->instance);
if (!groups_course_module_visible($mod)) {
continue;
}
}
if ($processed >= $display->maxevents) {
break;
}
$event->time = calendar_format_event_time($event, $now, $morehref);
$output[] = $event;
++$processed;
}
}
return $output;
}