当前位置: 首页>>代码示例>>PHP>>正文


PHP calendar_get_starting_weekday函数代码示例

本文整理汇总了PHP中calendar_get_starting_weekday函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_get_starting_weekday函数的具体用法?PHP calendar_get_starting_weekday怎么用?PHP calendar_get_starting_weekday使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calendar_get_starting_weekday函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: core_functions_test

 /**
  * Test all the core functions that use the calendar type system.
  *
  * @param string $type the calendar type we want to test
  */
 private function core_functions_test($type)
 {
     $this->set_calendar_type($type);
     // Get the calendar.
     $calendar = \core_calendar\type_factory::get_calendar_instance();
     // Test the userdate function.
     $this->assertEquals($calendar->timestamp_to_date_string($this->user->timecreated, '', 99, true, true), userdate($this->user->timecreated));
     // Test the calendar/lib.php functions.
     $this->assertEquals($calendar->get_weekdays(), calendar_get_days());
     $this->assertEquals($calendar->get_starting_weekday(), calendar_get_starting_weekday());
     $this->assertEquals($calendar->get_num_days_in_month('1986', '9'), calendar_days_in_month('9', '1986'));
     $this->assertEquals($calendar->get_next_month('1986', '9'), calendar_add_month('9', '1986'));
     $this->assertEquals($calendar->get_prev_month('1986', '9'), calendar_sub_month('9', '1986'));
     // Test the lib/moodle.php functions.
     $this->assertEquals($calendar->get_num_days_in_month('1986', '9'), days_in_month('9', '1986'));
     $this->assertEquals($calendar->get_weekday('1986', '9', '16'), dayofweek('16', '9', '1986'));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:22,代码来源:calendartype_test.php

示例2: calendar_get_mini

/**
 * Generates the HTML for a miniature calendar
 *
 * @param array $courses list of course to list events from
 * @param array $groups list of group
 * @param array $users user's info
 * @param int|bool $calmonth calendar month in numeric, default is set to false
 * @param int|bool $calyear calendar month in numeric, default is set to false
 * @param string|bool $placement the place/page the calendar is set to appear - passed on the the controls function
 * @param int|bool $courseid id of the course the calendar is displayed on - passed on the the controls function
 * @param int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth
 *     and $calyear to support multiple calendars
 * @return string $content return html table for mini calendar
 */
function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyear = false, $placement = false, $courseid = false, $time = 0)
{
    global $CFG, $OUTPUT;
    // Get the calendar type we are using.
    $calendartype = \core_calendar\type_factory::get_calendar_instance();
    $display = new stdClass();
    // Assume we are not displaying this month for now.
    $display->thismonth = false;
    $content = '';
    // Do this check for backwards compatibility. The core should be passing a timestamp rather than month and year.
    // If a month and year are passed they will be in Gregorian.
    if (!empty($calmonth) && !empty($calyear)) {
        // Ensure it is a valid date, else we will just set it to the current timestamp.
        if (checkdate($calmonth, 1, $calyear)) {
            $time = make_timestamp($calyear, $calmonth, 1);
        } else {
            $time = time();
        }
        $date = usergetdate($time);
        if ($calmonth == $date['mon'] && $calyear == $date['year']) {
            $display->thismonth = true;
        }
        // We can overwrite date now with the date used by the calendar type, if it is not Gregorian, otherwise
        // there is no need as it is already in Gregorian.
        if ($calendartype->get_name() != 'gregorian') {
            $date = $calendartype->timestamp_to_date_array($time);
        }
    } else {
        if (!empty($time)) {
            // Get the specified date in the calendar type being used.
            $date = $calendartype->timestamp_to_date_array($time);
            $thisdate = $calendartype->timestamp_to_date_array(time());
            if ($date['month'] == $thisdate['month'] && $date['year'] == $thisdate['year']) {
                $display->thismonth = true;
                // If we are the current month we want to set the date to the current date, not the start of the month.
                $date = $thisdate;
            }
        } else {
            // Get the current date in the calendar type being used.
            $time = time();
            $date = $calendartype->timestamp_to_date_array($time);
            $display->thismonth = true;
        }
    }
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display.
    // Get Gregorian date for the start of the month.
    $gregoriandate = $calendartype->convert_to_gregorian($date['year'], $date['mon'], 1);
    // Store the gregorian date values to be used later.
    list($gy, $gm, $gd, $gh, $gmin) = array($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
    // Get the max number of days in this month for this calendar type.
    $display->maxdays = calendar_days_in_month($m, $y);
    // Get the starting week day for this month.
    $startwday = dayofweek(1, $m, $y);
    // Get the days in a week.
    $daynames = calendar_get_days();
    // Store the number of days in a week.
    $numberofdaysinweek = $calendartype->get_num_weekdays();
    // Set the min and max weekday.
    $display->minwday = calendar_get_starting_weekday();
    $display->maxwday = $display->minwday + ($numberofdaysinweek - 1);
    // These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
    $display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
    $display->tend = $display->tstart + $display->maxdays * DAYSECS - 1;
    // Align the starting weekday to fall in our display range
    // This is simple, not foolproof.
    if ($startwday < $display->minwday) {
        $startwday += $numberofdaysinweek;
    }
    // Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
    $events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
    // Set event course class for course events
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // 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.
//.........这里部分代码省略.........
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:101,代码来源:lib.php

示例3: show_month_detailed

 /**
  * Displays a month in detail
  *
  * @param calendar_information $calendar
  * @param moodle_url $returnurl the url to return to
  * @return string
  */
 public function show_month_detailed(calendar_information $calendar, moodle_url $returnurl = null)
 {
     global $CFG;
     if (empty($returnurl)) {
         $returnurl = $this->page->url;
     }
     // Get the calendar type we are using.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Store the display settings.
     $display = new stdClass();
     $display->thismonth = false;
     // Get the specified date in the calendar type being used.
     $date = $calendartype->timestamp_to_date_array($calendar->time);
     $thisdate = $calendartype->timestamp_to_date_array(time());
     if ($date['mon'] == $thisdate['mon'] && $date['year'] == $thisdate['year']) {
         $display->thismonth = true;
         $date = $thisdate;
         $calendar->time = time();
     }
     // Get Gregorian date for the start of the month.
     $gregoriandate = $calendartype->convert_to_gregorian($date['year'], $date['mon'], 1);
     // Store the gregorian date values to be used later.
     list($gy, $gm, $gd, $gh, $gmin) = array($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
     // Get the starting week day for this month.
     $startwday = dayofweek(1, $date['mon'], $date['year']);
     // Get the days in a week.
     $daynames = calendar_get_days();
     // Store the number of days in a week.
     $numberofdaysinweek = $calendartype->get_num_weekdays();
     $display->minwday = calendar_get_starting_weekday();
     $display->maxwday = $display->minwday + ($numberofdaysinweek - 1);
     $display->maxdays = calendar_days_in_month($date['mon'], $date['year']);
     // These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
     $display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
     $display->tend = $display->tstart + $display->maxdays * DAYSECS - 1;
     // Align the starting weekday to fall in our display range
     // This is simple, not foolproof.
     if ($startwday < $display->minwday) {
         $startwday += $numberofdaysinweek;
     }
     // Get events from database
     $events = calendar_get_events($display->tstart, $display->tend, $calendar->users, $calendar->groups, $calendar->courses);
     if (!empty($events)) {
         foreach ($events as $eventid => $event) {
             $event = new calendar_event($event);
             if (!empty($event->modulename)) {
                 $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                 if (!\core_availability\info_module::is_user_visible($cm, 0, false)) {
                     unset($events[$eventid]);
                 }
             }
         }
     }
     // Extract information: events vs. time
     calendar_events_by_day($events, $date['mon'], $date['year'], $eventsbyday, $durationbyday, $typesbyday, $calendar->courses);
     $output = html_writer::start_tag('div', array('class' => 'header'));
     $output .= $this->course_filter_selector($returnurl, get_string('detailedmonthviewfor', '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', array('class' => 'header'));
     // Controls
     $output .= html_writer::tag('div', calendar_top_controls('month', array('id' => $calendar->courseid, 'time' => $calendar->time)), array('class' => 'controls'));
     $table = new html_table();
     $table->attributes = array('class' => 'calendarmonth calendartable');
     $table->summary = get_string('calendarheading', 'calendar', userdate($calendar->time, get_string('strftimemonthyear')));
     $table->data = array();
     // Get the day names as the header.
     $header = array();
     for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
         $header[] = $daynames[$i % $numberofdaysinweek]['shortname'];
     }
     $table->head = $header;
     // For the table display. $week is the row; $dayweek is the column.
     $week = 1;
     $dayweek = $startwday;
     $row = new html_table_row(array());
     // Paddding (the first week may have blank days in the beginning)
     for ($i = $display->minwday; $i < $startwday; ++$i) {
         $cell = new html_table_cell('&nbsp;');
         $cell->attributes = array('class' => 'nottoday dayblank');
         $row->cells[] = $cell;
     }
     // Now display all the calendar
     $weekend = CALENDAR_DEFAULT_WEEKEND;
     if (isset($CFG->calendar_weekend)) {
         $weekend = intval($CFG->calendar_weekend);
     }
     $daytime = $display->tstart - DAYSECS;
     for ($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
         $daytime = $daytime + DAYSECS;
         if ($dayweek > $display->maxwday) {
             // We need to change week (table row)
//.........这里部分代码省略.........
开发者ID:abhilash1994,项目名称:moodle,代码行数:101,代码来源:renderer.php

示例4: calendar_get_mini

/**
 * Generates the HTML for a miniature calendar
 *
 * @param array $courses list of course
 * @param array $groups list of group
 * @param array $users user's info
 * @param int $cal_month calendar month in numeric, default is set to false
 * @param int $cal_year calendar month in numeric, default is set to false
 * @return string $content return html table for mini calendar
 */
function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false)
{
    global $CFG, $USER, $OUTPUT;
    $display = new stdClass();
    $display->minwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
    $display->maxwday = $display->minwday + 6;
    $content = '';
    if (!empty($cal_month) && !empty($cal_year)) {
        $thisdate = usergetdate(time());
        // Date and time the user sees at his location
        if ($cal_month == $thisdate['mon'] && $cal_year == $thisdate['year']) {
            // Navigated to this month
            $date = $thisdate;
            $display->thismonth = true;
        } else {
            // Navigated to other month, let's do a nice trick and save us a lot of work...
            if (!checkdate($cal_month, 1, $cal_year)) {
                $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
                $display->thismonth = true;
            } else {
                $date = array('mday' => 1, 'mon' => $cal_month, 'year' => $cal_year);
                $display->thismonth = false;
            }
        }
    } else {
        $date = usergetdate(time());
        // Date and time the user sees at his location
        $display->thismonth = true;
    }
    // Fill in the variables we 're going to use, nice and tidy
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display
    $display->maxdays = calendar_days_in_month($m, $y);
    if (get_user_timezone_offset() < 99) {
        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y);
        // This is GMT
        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y);
        // GMT
    } else {
        // no timezone info specified
        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
    }
    $startwday = dayofweek(1, $m, $y);
    // Align the starting weekday to fall in our display range
    // This is simple, not foolproof.
    if ($startwday < $display->minwday) {
        $startwday += 7;
    }
    // TODO: THIS IS TEMPORARY CODE!
    // [pj] I was just reading through this and realized that I when writing this code I was probably
    // asking for trouble, as all these time manipulations seem to be unnecessary and a simple
    // make_timestamp would accomplish the same thing. So here goes a test:
    //$test_start = make_timestamp($y, $m, 1);
    //$test_end   = make_timestamp($y, $m, $display->maxdays, 23, 59, 59);
    //if($test_start != usertime($display->tstart) - dst_offset_on($display->tstart)) {
    //notify('Failed assertion in calendar/lib.php line 126; display->tstart = '.$display->tstart.', dst_offset = '.dst_offset_on($display->tstart).', usertime = '.usertime($display->tstart).', make_t = '.$test_start);
    //}
    //if($test_end != usertime($display->tend) - dst_offset_on($display->tend)) {
    //notify('Failed assertion in calendar/lib.php line 130; display->tend = '.$display->tend.', dst_offset = '.dst_offset_on($display->tend).', usertime = '.usertime($display->tend).', make_t = '.$test_end);
    //}
    // Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
    $events = calendar_get_events(usertime($display->tstart) - dst_offset_on($display->tstart), usertime($display->tend) - dst_offset_on($display->tend), $users, $groups, $courses);
    // Set event course class for course events
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // 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);
        }
    }
    // We want to have easy access by day, since the display is on a per-day basis.
    // Arguments passed by reference.
    //calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
    calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:lib.php

示例5: moodle_url

    $viewurl = new moodle_url('/calendar/view.php', array('view' => 'month'));
} else {
    $viewurl = new moodle_url('/calendar/view.php', array('view' => 'month', 'course' => $courseid));
}
navigation_node::override_active_url($viewurl);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
    $defaultlookahead = intval($CFG->calendar_lookahead);
}
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
    $defaultmaxevents = intval($CFG->calendar_maxevents);
}
$prefs = new stdClass();
$prefs->timeformat = get_user_preferences('calendar_timeformat', '');
$prefs->startwday = calendar_get_starting_weekday();
$prefs->maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$prefs->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$prefs->persistflt = get_user_preferences('calendar_persistflt', 0);
$form = new calendar_preferences_form($PAGE->url);
$form->set_data($prefs);
if ($form->is_cancelled()) {
    redirect($viewurl);
} else {
    if ($form->is_submitted() && $form->is_validated() && confirm_sesskey()) {
        $data = $form->get_data();
        if ($data->timeformat != CALENDAR_TF_12 && $data->timeformat != CALENDAR_TF_24) {
            $data->timeformat = '';
        }
        set_user_preference('calendar_timeformat', $data->timeformat);
        $data->startwday = intval($data->startwday);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:preferences.php

示例6: list

     if ($startmonthday > calendar_days_in_month($startmonth, $startyear)) {
         list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear);
         $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
     }
     $timestart = make_timestamp($startyear, $startmonth, $startmonthday);
     $endmonthday = $startmonthday + 7;
     $endmonth = $startmonth;
     $endyear = $startyear;
     if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
         list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
         $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
     }
     $timeend = make_timestamp($endyear, $endmonth, $endmonthday) - 1;
     break;
 case 'weeknext':
     $startweekday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
     $startmonthday = find_day_in_month($now['mday'] + 1, $startweekday, $now['mon'], $now['year']);
     $startmonth = $now['mon'];
     $startyear = $now['year'];
     if ($startmonthday > calendar_days_in_month($startmonth, $startyear)) {
         list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear);
         $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
     }
     $timestart = make_timestamp($startyear, $startmonth, $startmonthday);
     $endmonthday = $startmonthday + 7;
     $endmonth = $startmonth;
     $endyear = $startyear;
     if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
         list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
         $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
     }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:31,代码来源:export_execute.php

示例7: show_month_detailed

 /**
  * Displays a month in detail
  *
  * @param calendar_information $calendar
  * @return string
  */
 public function show_month_detailed(calendar_information $calendar, moodle_url $returnurl = null)
 {
     global $CFG;
     if (empty($returnurl)) {
         $returnurl = $this->page->url;
     }
     $date = usergetdate(time());
     $display = new stdClass();
     $display->minwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
     $display->maxwday = $display->minwday + 6;
     $display->thismonth = $date['mon'] == $calendar->month;
     $display->maxdays = calendar_days_in_month($calendar->month, $calendar->year);
     $startwday = 0;
     if (get_user_timezone_offset() < 99) {
         // We 'll keep these values as GMT here, and offset them when the time comes to query the db
         $display->tstart = gmmktime(0, 0, 0, $calendar->month, 1, $calendar->year);
         // This is GMT
         $display->tend = gmmktime(23, 59, 59, $calendar->month, $display->maxdays, $calendar->year);
         // GMT
         $startwday = gmdate('w', $display->tstart);
         // $display->tstart is already GMT, so don't use date(): messes with server's TZ
     } else {
         // no timezone info specified
         $display->tstart = mktime(0, 0, 0, $calendar->month, 1, $calendar->year);
         $display->tend = mktime(23, 59, 59, $calendar->month, $display->maxdays, $calendar->year);
         $startwday = date('w', $display->tstart);
         // $display->tstart not necessarily GMT, so use date()
     }
     // Align the starting weekday to fall in our display range
     if ($startwday < $display->minwday) {
         $startwday += 7;
     }
     // Get events from database
     $events = calendar_get_events(usertime($display->tstart), usertime($display->tend), $calendar->users, $calendar->groups, $calendar->courses);
     if (!empty($events)) {
         foreach ($events as $eventid => $event) {
             $event = new calendar_event($event);
             if (!empty($event->modulename)) {
                 $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                 if (!groups_course_module_visible($cm)) {
                     unset($events[$eventid]);
                 }
             }
         }
     }
     // Extract information: events vs. time
     calendar_events_by_day($events, $calendar->month, $calendar->year, $eventsbyday, $durationbyday, $typesbyday, $calendar->courses);
     $output = html_writer::start_tag('div', array('class' => 'header'));
     if (calendar_user_can_add_event($calendar->course)) {
         $output .= $this->add_event_button($calendar->course->id, null, $calendar->month, $calendar->year);
     }
     $output .= get_string('detailedmonthview', 'calendar') . ': ' . $this->course_filter_selector($returnurl);
     $output .= html_writer::end_tag('div', array('class' => 'header'));
     // Controls
     $output .= html_writer::tag('div', calendar_top_controls('month', array('id' => $calendar->courseid, 'm' => $calendar->month, 'y' => $calendar->year)), array('class' => 'controls'));
     $days = calendar_get_days();
     $table = new html_table();
     $table->attributes = array('class' => 'calendarmonth calendartable');
     $table->data = array();
     $header = new html_table_row();
     $header->attributes = array('class' => 'weekdays');
     $header->cells = array();
     for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
         // This uses the % operator to get the correct weekday no matter what shift we have
         // applied to the $display->minwday : $display->maxwday range from the default 0 : 6
         $cell = new html_table_cell(get_string($days[$i % 7], 'calendar'));
         $cell->header = true;
         $header->cells[] = $cell;
     }
     // For the table display. $week is the row; $dayweek is the column.
     $week = 1;
     $dayweek = $startwday;
     // Create an array of all the week days.
     $wdays = array(0 => '<strong>' . get_string('sunday', 'calendar') . '</strong>', 1 => '<strong>' . get_string('monday', 'calendar') . '</strong>', 2 => '<strong>' . get_string('tuesday', 'calendar') . '</strong>', 3 => '<strong>' . get_string('wednesday', 'calendar') . '</strong>', 4 => '<strong>' . get_string('thursday', 'calendar') . '</strong>', 5 => '<strong>' . get_string('friday', 'calendar') . '</strong>', 6 => '<strong>' . get_string('saturday', 'calendar') . '</strong>');
     // Loop only if the day offset is greater than 0.
     // This loop involves shifting the days around until the desired start day
     // is at the start of the array.
     $daycount = 0;
     while ($display->minwday > $daycount++) {
         $wdays_end = array_shift($wdays);
         array_push($wdays, $wdays_end);
     }
     // Now we set the (modified) array to the table header to be displayed.
     $table->head = $wdays;
     $row = new html_table_row(array());
     // Paddding (the first week may have blank days in the beginning)
     for ($i = $display->minwday; $i < $startwday; ++$i) {
         $cell = new html_table_cell('&nbsp;');
         $cell->attributes = array('class' => 'nottoday');
         $row->cells[] = $cell;
     }
     // Now display all the calendar
     $weekend = CALENDAR_DEFAULT_WEEKEND;
     if (isset($CFG->calendar_weekend)) {
//.........这里部分代码省略.........
开发者ID:rosenclever,项目名称:moodle,代码行数:101,代码来源:renderer.php

示例8: optional_param

$userid = optional_param('id', $USER->id, PARAM_INT);
// User id.
$PAGE->set_url('/user/calendar.php', array('id' => $userid));
list($user, $course) = useredit_setup_preference_page($userid, SITEID);
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
    $defaultlookahead = intval($CFG->calendar_lookahead);
}
$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
    $defaultmaxevents = intval($CFG->calendar_maxevents);
}
// Create form.
$calendarform = new core_user\form\calendar_form(null, array('userid' => $user->id));
$user->timeformat = get_user_preferences('calendar_timeformat', '');
$user->startwday = calendar_get_starting_weekday();
$user->maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$user->lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);
$user->persistflt = get_user_preferences('calendar_persistflt', 0);
$calendarform->set_data($user);
$redirect = new moodle_url("/user/preferences.php", array('userid' => $user->id));
if ($calendarform->is_cancelled()) {
    redirect($redirect);
} else {
    if ($calendarform->is_submitted() && $calendarform->is_validated() && confirm_sesskey()) {
        $data = $calendarform->get_data();
        // Time format.
        if ($data->timeformat != CALENDAR_TF_12 && $data->timeformat != CALENDAR_TF_24) {
            $data->timeformat = '';
        }
        set_user_preference('calendar_timeformat', $data->timeformat);
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:calendar.php

示例9: find_day_in_month

         $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
     }
     $gregoriandate = $calendartype->convert_to_gregorian($startyear, $startmonth, $startmonthday);
     $timestart = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
     $endmonthday = $startmonthday + $numberofdaysinweek;
     $endmonth = $startmonth;
     $endyear = $startyear;
     if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
         list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
         $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
     }
     $gregoriandate = $calendartype->convert_to_gregorian($endyear, $endmonth, $endmonthday);
     $timeend = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
     break;
 case 'weeknext':
     $startweekday = calendar_get_starting_weekday();
     $startmonthday = find_day_in_month($now['mday'] + 1, $startweekday, $now['mon'], $now['year']);
     $startmonth = $now['mon'];
     $startyear = $now['year'];
     if ($startmonthday > calendar_days_in_month($startmonth, $startyear)) {
         list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear);
         $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
     }
     $gregoriandate = $calendartype->convert_to_gregorian($startyear, $startmonth, $startmonthday);
     $timestart = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
     $endmonthday = $startmonthday + $numberofdaysinweek;
     $endmonth = $startmonth;
     $endyear = $startyear;
     if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
         list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
         $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
开发者ID:abhilash1994,项目名称:moodle,代码行数:31,代码来源:export_execute.php

示例10: get_display_info

function get_display_info($d, $m, $y) {
    $display = new stdClass;
    $display->minwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
    $display->maxwday = $display->minwday + 6;

    $thisdate = usergetdate(time()); // Time and day at the user's location
    if ($m == $thisdate['mon'] && $y == $thisdate['year']) {
        // Navigated to this month
        $date = $thisdate;
        $display->thismonth = true;
    }
    else {
        // Navigated to other month, let's do a nice trick and save us a lot of work...
        if (!checkdate($m, 1, $y)) {
            $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
            $display->thismonth = true;
        }
        else {
            $date = array('mday' => 1, 'mon' => $m, 'year' => $y);
            $display->thismonth = false;
        }
    }

    // Fill in the variables we 're going to use, nice and tidy
    list($day, $month, $year) = array($date['mday'], $date['mon'], $date['year']); // This is what we want to display
    $display->maxdays = calendar_days_in_month($m, $y);

    $startwday = 0;
    if (get_user_timezone_offset() < 99) {
        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y); // This is GMT
        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y); // GMT
        $startwday = gmdate('w', $display->tstart); // $display->tstart is already GMT, so don't use date(): messes with server's TZ
    } else {
        // no timezone info specified
        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
        $startwday = date('w', $display->tstart); // $display->tstart not necessarily GMT, so use date()
    }

    // Align the starting weekday to fall in our display range
    if ($startwday < $display->minwday) {
        $startwday += 7;
    }

    $display->startwday = $startwday;
    return $display;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:48,代码来源:calendar.php


注:本文中的calendar_get_starting_weekday函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。