本文整理汇总了PHP中calendar_day_representation函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_day_representation函数的具体用法?PHP calendar_day_representation怎么用?PHP calendar_day_representation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了calendar_day_representation函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calendar_format_event_time
/**
* Get event format time
*
* @param calendar_event $event event object
* @param int $now current time in gmt
* @param array $linkparams list of params for event link
* @param bool $usecommonwords the words as formatted date/time.
* @param int $showtime determine the show time GMT timestamp
* @return string $eventtime link/string for event time
*/
function calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime = 0)
{
$starttime = $event->timestart;
$endtime = $event->timestart + $event->timeduration;
if (empty($linkparams) || !is_array($linkparams)) {
$linkparams = array();
}
$linkparams['view'] = 'day';
// OK, now to get a meaningful display...
// Check if there is a duration for this event.
if ($event->timeduration) {
// Get the midnight of the day the event will start.
$usermidnightstart = usergetmidnight($starttime);
// Get the midnight of the day the event will end.
$usermidnightend = usergetmidnight($endtime);
// Check if we will still be on the same day.
if ($usermidnightstart == $usermidnightend) {
// Check if we are running all day.
if ($event->timeduration == DAYSECS) {
$time = get_string('allday', 'calendar');
} else {
// Specify the time we will be running this from.
$datestart = calendar_time_representation($starttime);
$dateend = calendar_time_representation($endtime);
$time = $datestart . ' <strong>»</strong> ' . $dateend;
}
// Set printable representation.
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = html_writer::link($url, $day) . ', ' . $time;
} else {
$eventtime = $time;
}
} else {
// It must spans two or more days.
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation.
if ($now >= $usermidnightstart && $now < $usermidnightstart + DAYSECS) {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = $timestart . ' <strong>»</strong> ' . html_writer::link($url, $dayend) . $timeend;
} else {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = html_writer::link($url, $daystart) . $timestart . ' <strong>»</strong> ';
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
$eventtime .= html_writer::link($url, $dayend) . $timeend;
}
}
} else {
// There is no time duration.
$time = calendar_time_representation($event->timestart);
// Set printable representation.
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $starttime);
$eventtime = html_writer::link($url, $day) . ', ' . trim($time);
} else {
$eventtime = $time;
}
}
// Check if It has expired.
if ($event->timestart + $event->timeduration < $now) {
$eventtime = '<span class="dimmed_text">' . str_replace(' href=', ' class="dimmed" href=', $eventtime) . '</span>';
}
return $eventtime;
}
示例2: calendar_format_event_time
function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true, $showtime = 0)
{
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if ($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
} else {
$usermidnightend = $usermidnightstart;
}
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if ($event->timeduration) {
// It has a duration
if ($usermidnightstart == $usermidnightend || $event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399) || $event->timestart + $event->timeduration <= $usermidnightstart + 86400) {
// But it's all on the same day
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
$time = $timestart . ' <strong>»</strong> ' . $timeend;
if ($event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399)) {
$time = get_string('allday', 'calendar');
}
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ', ' . $time;
} else {
$eventtime = $time;
}
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords) . ', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
if ($now >= $usermidnightstart && $now < $usermidnightstart + 86400) {
$eventtime = $timestart . ' <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
} else {
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . $timestart . ' <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . $timeend;
}
}
} else {
$time = ' ';
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . trim($time);
} else {
$eventtime = $time;
}
}
if ($event->timestart + $event->timeduration < $now) {
// It has expired
$eventtime = '<span class="dimmed_text">' . str_replace(' href=', ' class="dimmed" href=', $eventtime) . '</span>';
}
return $eventtime;
}
示例3: friendly_datetime
/**
* Return friendly text date (e.g. "Today", "Tomorrow") in a <time> tag
* @return string
*/
public function friendly_datetime($time)
{
$timetext = \calendar_day_representation($time);
$timetext .= ', ' . \calendar_time_representation($time);
$datetime = date(DateTime::W3C, $time);
return html_writer::tag('time', $timetext, array('datetime' => $datetime));
}
示例4: bigbluebuttonbn_process_post_save
/**
* Runs any processes that must be run
* after a bigbluebuttonbn insert/update
*
* @global object
* @param object $bigbluebuttonbn BigBlueButtonBN form data
* @return void
**/
function bigbluebuttonbn_process_post_save(&$bigbluebuttonbn)
{
global $DB, $CFG, $USER;
// Now that an id was assigned, generate and set the meetingid property based on
// [Moodle Instance + Activity ID + BBB Secret] (but only for new activities)
if (isset($bigbluebuttonbn->add) && !empty($bigbluebuttonbn->add)) {
$bigbluebuttonbn_meetingid = sha1($CFG->wwwroot . $bigbluebuttonbn->id . bigbluebuttonbn_get_cfg_shared_secret());
$DB->set_field('bigbluebuttonbn', 'meetingid', $bigbluebuttonbn_meetingid, array('id' => $bigbluebuttonbn->id));
$action = get_string('mod_form_field_notification_msg_created', 'bigbluebuttonbn');
} else {
$action = get_string('mod_form_field_notification_msg_modified', 'bigbluebuttonbn');
}
// Add evento to the calendar when if openingtime is set
if (isset($bigbluebuttonbn->openingtime) && $bigbluebuttonbn->openingtime) {
$event = new stdClass();
$event->name = $bigbluebuttonbn->name;
$event->courseid = $bigbluebuttonbn->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'bigbluebuttonbn';
$event->instance = $bigbluebuttonbn->id;
$event->timestart = $bigbluebuttonbn->openingtime;
if ($bigbluebuttonbn->closingtime) {
$event->durationtime = $bigbluebuttonbn->closingtime - $bigbluebuttonbn->openingtime;
} else {
$event->durationtime = 0;
}
if ($event->id = $DB->get_field('event', 'id', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id))) {
$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
calendar_event::create($event);
}
} else {
$DB->delete_records('event', array('modulename' => 'bigbluebuttonbn', 'instance' => $bigbluebuttonbn->id));
}
if (isset($bigbluebuttonbn->notification) && $bigbluebuttonbn->notification) {
// Prepare message
$msg = new stdClass();
/// Build the message_body
$msg->action = $action;
$msg->activity_type = "";
$msg->activity_title = $bigbluebuttonbn->name;
/// Add the meeting details to the message_body
$msg->action = ucfirst($action);
$msg->activity_description = "";
if (!empty($bigbluebuttonbn->intro)) {
$msg->activity_description = trim($bigbluebuttonbn->intro);
}
$msg->activity_openingtime = "";
if ($bigbluebuttonbn->openingtime) {
$date = new stdClass();
$date->day = calendar_day_representation($bigbluebuttonbn->openingtime);
$date->time = calendar_time_representation($bigbluebuttonbn->openingtime);
$msg->activity_openingtime = get_string('email_date', 'bigbluebuttonbn', $date);
}
$msg->activity_closingtime = "";
if ($bigbluebuttonbn->closingtime) {
$date = new stdClass();
$date->day = calendar_day_representation($bigbluebuttonbn->closingtime);
$date->time = calendar_time_representation($bigbluebuttonbn->closingtime);
$msg->activity_closingtime = get_string('email_date', 'bigbluebuttonbn', $date);
}
$msg->activity_owner = fullname($USER);
$message_text = get_string('email_body_notification', 'bigbluebuttonbn', $msg);
// Send notification to all users enrolled
bigbluebuttonbn_send_notification($USER, $bigbluebuttonbn, $message_text);
}
}
示例5: calendar_format_event_time
/**
* Get event format time
*
* @param calendar_event $event event object
* @param int $now current time in gmt
* @param array $linkparams list of params for event link
* @param bool $usecommonwords the words as formatted date/time.
* @param int $showtime determine the show time GMT timestamp
* @return string $eventtime link/string for event time
*/
function calendar_format_event_time($event, $now, $linkparams = null, $usecommonwords = true, $showtime=0) {
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
}
else {
$usermidnightend = $usermidnightstart;
}
if (empty($linkparams) || !is_array($linkparams)) {
$linkparams = array();
}
$linkparams['view'] = 'day';
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if($event->timeduration) {
// It has a duration
if($usermidnightstart == $usermidnightend ||
($event->timestart == $usermidnightstart) && ($event->timeduration == 86400 || $event->timeduration == 86399) ||
($event->timestart + $event->timeduration <= $usermidnightstart + 86400)) {
// But it's all on the same day
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
$time = $timestart.' <strong>»</strong> '.$timeend;
if ($event->timestart == $usermidnightstart && ($event->timeduration == 86400 || $event->timeduration == 86399)) {
$time = get_string('allday', 'calendar');
}
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = html_writer::link($url, $day).', '.$time;
} else {
$eventtime = $time;
}
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords).', ';
if ($showtime == $usermidnightstart) {
$daystart = '';
}
$timestart = calendar_time_representation($event->timestart);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords).', ';
if ($showtime == $usermidnightend) {
$dayend = '';
}
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
if ($now >= $usermidnightstart && $now < ($usermidnightstart + 86400)) {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = $timestart.' <strong>»</strong> '.html_writer::link($url, $dayend).$timeend;
} else {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $enddate['mday'], $enddate['mon'], $enddate['year']);
$eventtime = html_writer::link($url, $daystart).$timestart.' <strong>»</strong> ';
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $startdate['mday'], $startdate['mon'], $startdate['year']);
$eventtime .= html_writer::link($url, $dayend).$timeend;
}
}
} else {
$time = calendar_time_representation($event->timestart);
// Set printable representation
if (!$showtime) {
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $linkparams), $startdate['mday'], $startdate['mon'], $startdate['year']);
$eventtime = html_writer::link($url, $day).', '.trim($time);
} else {
$eventtime = $time;
}
}
if($event->timestart + $event->timeduration < $now) {
// It has expired
$eventtime = '<span class="dimmed_text">'.str_replace(' href=', ' class="dimmed" href=', $eventtime).'</span>';
}
return $eventtime;
}
示例6: calendar_format_event_time
function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true)
{
$startdate = usergetdate($event->timestart);
$enddate = usergetdate($event->timestart + $event->timeduration);
$usermidnightstart = usergetmidnight($event->timestart);
if ($event->timeduration) {
// To avoid doing the math if one IF is enough :)
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
} else {
$usermidnightend = $usermidnightstart;
}
// OK, now to get a meaningful display...
// First of all we have to construct a human-readable date/time representation
if ($event->timestart + $event->timeduration < $now) {
// It has expired, so we don't care about duration
$day = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
$time = calendar_time_representation($event->timestart + $event->timeduration);
// This var always has the printable time representation
$eventtime = '<span class="dimmed_text"><a class="dimmed" href="' . calendar_get_link_href(CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . '">' . $day . '</a> (' . $time . ')</span>';
} else {
if ($event->timeduration) {
// It has a duration
if ($usermidnightstart == $usermidnightend) {
// But it's all on the same day
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ' (' . $timestart . ' <strong>»</strong> ' . $timeend . ')';
} else {
// It spans two or more days
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords);
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
$timestart = calendar_time_representation($event->timestart);
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . ' (' . $timestart . ') <strong>»</strong> ' . calendar_get_link_tag($dayend, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $enddate['mday'], $enddate['mon'], $enddate['year']) . ' (' . $timeend . ')';
}
} else {
// It's an "instantaneous" event
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
$time = calendar_time_representation($event->timestart);
// Set printable representation
$eventtime = calendar_get_link_tag($day, CALENDAR_URL . 'view.php?view=day' . $morehref . '&', $startdate['mday'], $startdate['mon'], $startdate['year']) . ' (' . $time . ')';
}
}
return $eventtime;
}
示例7: meeting_times
/**
* Meeting times.
*
* @param $times
* @return string
*/
public function meeting_times($times)
{
$startday = calendar_day_representation($times->start);
$endday = calendar_day_representation($times->end);
$endtime = calendar_time_representation($times->end);
$startyear = userdate($times->start, '%y');
$endyear = userdate($times->end, '%y');
$startmonth = userdate($times->start, '%m');
$endmonth = userdate($times->end, '%m');
$openended = date('Y-m-d', $times->end) === '3000-01-01';
$startiscurrentyear = $startyear === userdate(time(), '%y');
if ($startiscurrentyear && ($openended || $startyear === $endyear)) {
$datesstr = $this->datetime($times->start);
} else {
$visualstart = userdate($times->start, get_string('strftimedatetime', 'langconfig'));
$datesstr = $this->datetime($times->start, $visualstart);
}
if ($startday === $endday && $startmonth === $endmonth && $startyear === $endyear) {
$datesstr .= ' - ' . $this->datetime($times->end, $endtime);
} else {
if ($openended) {
$datesstr .= ' (' . get_string('openended', 'mod_collaborate') . ')';
} else {
if ($startyear === $endyear) {
$datesstr .= ' - ' . $this->datetime($times->end);
} else {
$visualend = userdate($times->end, get_string('strftimedatetime', 'langconfig'));
$datesstr .= ' - ' . $this->datetime($times->end, $visualend);
}
}
}
return $datesstr;
}