• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP core_calendar\type_factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: form_init_date_js

/**
 * Initalize javascript for date type form element
 *
 * @staticvar bool $done make sure it gets initalize once.
 * @global moodle_page $PAGE
 */
function form_init_date_js()
{
    global $PAGE;
    static $done = false;
    if (!$done) {
        $calendar = \core_calendar\type_factory::get_calendar_instance();
        $module = 'moodle-form-dateselector';
        $function = 'M.form.dateselector.init_date_selectors';
        $config = array(array('firstdayofweek' => $calendar->get_starting_weekday(), 'mon' => date_format_string(strtotime("Monday"), '%a', 99), 'tue' => date_format_string(strtotime("Tuesday"), '%a', 99), 'wed' => date_format_string(strtotime("Wednesday"), '%a', 99), 'thu' => date_format_string(strtotime("Thursday"), '%a', 99), 'fri' => date_format_string(strtotime("Friday"), '%a', 99), 'sat' => date_format_string(strtotime("Saturday"), '%a', 99), 'sun' => date_format_string(strtotime("Sunday"), '%a', 99), 'january' => date_format_string(strtotime("January 1"), '%B', 99), 'february' => date_format_string(strtotime("February 1"), '%B', 99), 'march' => date_format_string(strtotime("March 1"), '%B', 99), 'april' => date_format_string(strtotime("April 1"), '%B', 99), 'may' => date_format_string(strtotime("May 1"), '%B', 99), 'june' => date_format_string(strtotime("June 1"), '%B', 99), 'july' => date_format_string(strtotime("July 1"), '%B', 99), 'august' => date_format_string(strtotime("August 1"), '%B', 99), 'september' => date_format_string(strtotime("September 1"), '%B', 99), 'october' => date_format_string(strtotime("October 1"), '%B', 99), 'november' => date_format_string(strtotime("November 1"), '%B', 99), 'december' => date_format_string(strtotime("December 1"), '%B', 99)));
        $PAGE->requires->yui_module($module, $function, $config);
        $done = true;
    }
}
开发者ID:elie89,项目名称:moodle,代码行数:19,代码来源:formslib.php


示例2: edit_field_add

 /**
  * Handles editing datetime fields.
  *
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Check if the field is required.
     if ($this->field->required) {
         $optional = false;
     } else {
         $optional = true;
     }
     // Convert the year stored in the DB as gregorian to that used by the calendar type.
     $startdate = $calendartype->convert_from_gregorian($this->field->param1, 1, 1);
     $stopdate = $calendartype->convert_from_gregorian($this->field->param2, 1, 1);
     $attributes = array('startyear' => $startdate['year'], 'stopyear' => $stopdate['year'], 'optional' => $optional);
     // Check if they wanted to include time as well.
     if (!empty($this->field->param3)) {
         $mform->addElement('date_time_selector', $this->inputname, format_string($this->field->name), $attributes);
     } else {
         $mform->addElement('date_selector', $this->inputname, format_string($this->field->name), $attributes);
     }
     $mform->setType($this->inputname, PARAM_INT);
     $mform->setDefault($this->inputname, time());
 }
开发者ID:janeklb,项目名称:moodle,代码行数:28,代码来源:field.class.php


示例3: useredit_shared_definition

/**
 * Powerful function that is used by edit and editadvanced to add common form elements/rules/etc.
 *
 * @param moodleform $mform
 * @param array $editoroptions
 * @param array $filemanageroptions
 * @param stdClass $user
 */
function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions, $user)
{
    global $CFG, $USER, $DB;
    if ($user->id > 0) {
        useredit_load_preferences($user, false);
    }
    $strrequired = get_string('required');
    // Add the necessary names.
    foreach (useredit_get_required_name_fields() as $fullname) {
        $mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
        $mform->addRule($fullname, $strrequired, 'required', null, 'client');
        $mform->setType($fullname, PARAM_NOTAGS);
    }
    $enabledusernamefields = useredit_get_enabled_name_fields();
    // Add the enabled additional name fields.
    foreach ($enabledusernamefields as $addname) {
        $mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
        $mform->setType($addname, PARAM_NOTAGS);
    }
    // Do not show email field if change confirmation is pending.
    if ($user->id > 0 and !empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
        $notice = get_string('emailchangepending', 'auth', $user);
        $notice .= '<br /><a href="edit.php?cancelemailchange=1&amp;id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
        $mform->addElement('static', 'emailpending', get_string('email'), $notice);
    } else {
        $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
        $mform->addRule('email', $strrequired, 'required', null, 'client');
        $mform->setType('email', PARAM_RAW_TRIMMED);
    }
    $choices = array();
    $choices['0'] = get_string('emaildisplayno');
    $choices['1'] = get_string('emaildisplayyes');
    $choices['2'] = get_string('emaildisplaycourse');
    $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
    $mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
    $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
    $mform->setType('city', PARAM_TEXT);
    if (!empty($CFG->defaultcity)) {
        $mform->setDefault('city', $CFG->defaultcity);
    }
    $choices = get_string_manager()->get_list_of_countries();
    $choices = array('' => get_string('selectacountry') . '...') + $choices;
    $mform->addElement('select', 'country', get_string('selectacountry'), $choices);
    if (!empty($CFG->country)) {
        $mform->setDefault('country', $CFG->country);
    }
    if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) {
        $choices = core_date::get_list_of_timezones($CFG->forcetimezone);
        $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
        $mform->addElement('hidden', 'timezone');
        $mform->setType('timezone', PARAM_TIMEZONE);
    } else {
        $choices = core_date::get_list_of_timezones($user->timezone, true);
        $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
    }
    // Multi-Calendar Support - see MDL-18375.
    $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
    // We do not want to show this option unless there is more than one calendar type to display.
    if (count($calendartypes) > 1) {
        $mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
        $mform->setDefault('calendartype', $CFG->calendartype);
    }
    if (!empty($CFG->allowuserthemes)) {
        $choices = array();
        $choices[''] = get_string('default');
        $themes = get_list_of_themes();
        foreach ($themes as $key => $theme) {
            if (empty($theme->hidefromselector)) {
                $choices[$key] = get_string('pluginname', 'theme_' . $theme->name);
            }
        }
        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
    }
    $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
    $mform->setType('description_editor', PARAM_CLEANHTML);
    $mform->addHelpButton('description_editor', 'userdescription');
    if (empty($USER->newadminuser)) {
        $mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
        if (!empty($CFG->enablegravatar)) {
            $mform->addElement('html', html_writer::tag('p', get_string('gravatarenabled')));
        }
        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));
        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', 0);
        $mform->addElement('filemanager', 'imagefile', get_string('newpicture'), '', $filemanageroptions);
        $mform->addHelpButton('imagefile', 'newpicture');
        $mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
        $mform->setType('imagealt', PARAM_TEXT);
    }
    // Display user name fields that are not currenlty enabled here if there are any.
    $disabledusernamefields = useredit_get_disabled_name_fields($enabledusernamefields);
    if (count($disabledusernamefields) > 0) {
//.........这里部分代码省略.........
开发者ID:Keneth1212,项目名称:moodle,代码行数:101,代码来源:editlib.php


示例4: definition_after_data

 /**
  * Extend the form definition after the data has been parsed.
  */
 public function definition_after_data()
 {
     global $CFG;
     $mform = $this->_form;
     // If calendar type does not exist, use site default calendar type.
     if ($calendarselected = $mform->getElementValue('calendartype')) {
         if (is_array($calendarselected)) {
             // There are multiple calendar types available.
             $calendar = reset($calendarselected);
         } else {
             // There is only one calendar type available.
             $calendar = $calendarselected;
         }
         // Check calendar type exists.
         if (!array_key_exists($calendar, \core_calendar\type_factory::get_list_of_calendar_types())) {
             $calendartypeel = $mform->getElement('calendartype');
             $calendartypeel->setValue($CFG->calendartype);
         }
     }
 }
开发者ID:janeklb,项目名称:moodle,代码行数:23,代码来源:calendar_form.php


示例5: get_timestamp_from_value

 /**
  *
  */
 protected function get_timestamp_from_value($value)
 {
     if (empty($value)) {
         return null;
     }
     $timestamp = null;
     // Timestamp or time string.
     if (!is_array($value)) {
         if ((string) (int) $value === (string) $value && $value <= PHP_INT_MAX && $value >= ~PHP_INT_MAX) {
             // It's a timestamp.
             $timestamp = $value;
         } else {
             if ($value = strtotime($value)) {
                 // It's a valid time string.
                 $timestamp = $value;
             }
         }
     } else {
         // Assuming any of year, month, day, hour, minute is passed.
         $enabled = 0;
         $year = 0;
         $month = 1;
         $day = 1;
         $hour = 0;
         $minute = 0;
         foreach ($value as $name => $val) {
             if (!empty($val)) {
                 ${$name} = $val;
             }
         }
         if ($enabled and $year) {
             $calendartype = \core_calendar\type_factory::get_calendar_instance();
             $gregoriandate = $calendartype->convert_to_gregorian($year, $month, $day, $hour, $minute);
             $timestamp = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
         }
     }
     return $timestamp;
 }
开发者ID:vaenda,项目名称:moodle-mod_dataform,代码行数:41,代码来源:time.php


示例6: user_update_user

/**
 * Update a user with a user object (will compare against the ID)
 *
 * @param stdClass $user the user to update
 * @param bool $updatepassword if true, authentication plugin will update password.
 * @param bool $triggerevent set false if user_updated event should not be triggred.
 */
function user_update_user($user, $updatepassword = true, $triggerevent = true)
{
    global $DB;
    // set the timecreate field to the current time
    if (!is_object($user)) {
        $user = (object) $user;
    }
    //check username
    if (isset($user->username)) {
        if ($user->username !== core_text::strtolower($user->username)) {
            throw new moodle_exception('usernamelowercase');
        } else {
            if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {
                throw new moodle_exception('invalidusername');
            }
        }
    }
    // Unset password here, for updating later, if password update is required.
    if ($updatepassword && isset($user->password)) {
        //check password toward the password policy
        if (!check_password_policy($user->password, $errmsg)) {
            throw new moodle_exception($errmsg);
        }
        $passwd = $user->password;
        unset($user->password);
    }
    // Make sure calendartype, if set, is valid.
    if (!empty($user->calendartype)) {
        $availablecalendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
        // If it doesn't exist, then unset this value, we do not want to update the user's value.
        if (empty($availablecalendartypes[$user->calendartype])) {
            unset($user->calendartype);
        }
    } else {
        // Unset this variable, must be an empty string, which we do not want to update the calendartype to.
        unset($user->calendartype);
    }
    $user->timemodified = time();
    $DB->update_record('user', $user);
    if ($updatepassword) {
        // Get full user record.
        $updateduser = $DB->get_record('user', array('id' => $user->id));
        // if password was set, then update its hash
        if (isset($passwd)) {
            $authplugin = get_auth_plugin($updateduser->auth);
            if ($authplugin->can_change_password()) {
                $authplugin->user_update_password($updateduser, $passwd);
            }
        }
    }
    // Trigger event if required.
    if ($triggerevent) {
        \core\event\user_updated::create_from_userid($user->id)->trigger();
    }
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:62,代码来源:lib.php


示例7: calendar_events_by_day

/**
 * Get per-day basis events
 *
 * @param array $events list of events
 * @param int $month the number of the month
 * @param int $year the number of the year
 * @param array $eventsbyday event on specific day
 * @param array $durationbyday duration of the event in days
 * @param array $typesbyday event type (eg: global, course, user, or group)
 * @param array $courses list of courses
 * @return void
 */
function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday, &$courses)
{
    // Get the calendar type we are using.
    $calendartype = \core_calendar\type_factory::get_calendar_instance();
    $eventsbyday = array();
    $typesbyday = array();
    $durationbyday = array();
    if ($events === false) {
        return;
    }
    foreach ($events as $event) {
        $startdate = $calendartype->timestamp_to_date_array($event->timestart);
        // Set end date = start date if no duration
        if ($event->timeduration) {
            $enddate = $calendartype->timestamp_to_date_array($event->timestart + $event->timeduration - 1);
        } else {
            $enddate = $startdate;
        }
        // Simple arithmetic: $year * 13 + $month is a distinct integer for each distinct ($year, $month) pair
        if (!($startdate['year'] * 13 + $startdate['mon'] <= $year * 13 + $month) && $enddate['year'] * 13 + $enddate['mon'] >= $year * 13 + $month) {
            // Out of bounds
            continue;
        }
        $eventdaystart = intval($startdate['mday']);
        if ($startdate['mon'] == $month && $startdate['year'] == $year) {
            // Give the event to its day
            $eventsbyday[$eventdaystart][] = $event->id;
            // Mark the day as having such an event
            if ($event->courseid == SITEID && $event->groupid == 0) {
                $typesbyday[$eventdaystart]['startglobal'] = true;
                // Set event class for global event
                $events[$event->id]->class = 'calendar_event_global';
            } else {
                if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
                    $typesbyday[$eventdaystart]['startcourse'] = true;
                    // Set event class for course event
                    $events[$event->id]->class = 'calendar_event_course';
                } else {
                    if ($event->groupid) {
                        $typesbyday[$eventdaystart]['startgroup'] = true;
                        // Set event class for group event
                        $events[$event->id]->class = 'calendar_event_group';
                    } else {
                        if ($event->userid) {
                            $typesbyday[$eventdaystart]['startuser'] = true;
                            // Set event class for user event
                            $events[$event->id]->class = 'calendar_event_user';
                        }
                    }
                }
            }
        }
        if ($event->timeduration == 0) {
            // Proceed with the next
            continue;
        }
        // The event starts on $month $year or before. So...
        $lowerbound = $startdate['mon'] == $month && $startdate['year'] == $year ? intval($startdate['mday']) : 0;
        // Also, it ends on $month $year or later...
        $upperbound = $enddate['mon'] == $month && $enddate['year'] == $year ? intval($enddate['mday']) : calendar_days_in_month($month, $year);
        // Mark all days between $lowerbound and $upperbound (inclusive) as duration
        for ($i = $lowerbound + 1; $i <= $upperbound; ++$i) {
            $durationbyday[$i][] = $event->id;
            if ($event->courseid == SITEID && $event->groupid == 0) {
                $typesbyday[$i]['durationglobal'] = true;
            } else {
                if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
                    $typesbyday[$i]['durationcourse'] = true;
                } else {
                    if ($event->groupid) {
                        $typesbyday[$i]['durationgroup'] = true;
                    } else {
                        if ($event->userid) {
                            $typesbyday[$i]['durationuser'] = true;
                        }
                    }
                }
            }
        }
    }
    return;
}
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:94,代码来源:lib.php


示例8: get_javascript_init_params

 protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/formslib.php';
     // Support internationalised calendars.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Get current date, but set time to 00:00 (to make it easier to
     // specify whole days) and change name of mday field to match below.
     $wrongfields = $calendartype->timestamp_to_date_array(time());
     $current = array('day' => $wrongfields['mday'], 'month' => $wrongfields['mon'], 'year' => $wrongfields['year'], 'hour' => 0, 'minute' => 0);
     // Time part is handled the same everywhere.
     $hours = array();
     for ($i = 0; $i <= 23; $i++) {
         $hours[$i] = sprintf("%02d", $i);
     }
     $minutes = array();
     for ($i = 0; $i < 60; $i += 5) {
         $minutes[$i] = sprintf("%02d", $i);
     }
     // List date fields.
     $fields = $calendartype->get_date_order($calendartype->get_min_year(), $calendartype->get_max_year());
     // Add time fields - in RTL mode these are switched.
     $fields['split'] = '/';
     if (right_to_left()) {
         $fields['minute'] = $minutes;
         $fields['colon'] = ':';
         $fields['hour'] = $hours;
     } else {
         $fields['hour'] = $hours;
         $fields['colon'] = ':';
         $fields['minute'] = $minutes;
     }
     // Output all date fields.
     $html = '<span class="availability-group">';
     foreach ($fields as $field => $options) {
         if ($options === '/') {
             $html = rtrim($html);
             // In Gregorian calendar mode only, we support a date selector popup, reusing
             // code from form to ensure consistency.
             if ($calendartype->get_name() === 'gregorian' && self::DATE_SELECTOR_SUPPORTED) {
                 $image = $OUTPUT->pix_icon('i/calendar', get_string('calendar', 'calendar'), 'moodle');
                 $html .= ' ' . \html_writer::link('#', $image, array('name' => 'x[calendar]'));
                 form_init_date_js();
             }
             $html .= '</span> <span class="availability-group">';
             continue;
         }
         if ($options === ':') {
             $html .= ': ';
             continue;
         }
         $html .= \html_writer::start_tag('label');
         $html .= \html_writer::span(get_string($field) . ' ', 'accesshide');
         // NOTE: The fields need to have these weird names in order that they
         // match the standard Moodle form control, otherwise the date selector
         // won't find them.
         $html .= \html_writer::start_tag('select', array('name' => 'x[' . $field . ']', 'class' => 'custom-select'));
         foreach ($options as $key => $value) {
             $params = array('value' => $key);
             if ($current[$field] == $key) {
                 $params['selected'] = 'selected';
             }
             $html .= \html_writer::tag('option', s($value), $params);
         }
         $html .= \html_writer::end_tag('select');
         $html .= \html_writer::end_tag('label');
         $html .= ' ';
     }
     $html = rtrim($html) . '</span>';
     // Also get the time that corresponds to this default date.
     $time = self::get_time_from_fields($current['year'], $current['month'], $current['day'], $current['hour'], $current['minute']);
     return array($html, $time);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:73,代码来源:frontend.php


示例9: get_string

$calendar->prepare_for_view($course, $courses);
$pagetitle = get_string('export', 'calendar');
// Print title and header
if ($issite) {
    $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)));
}
$link = new moodle_url(CALENDAR_URL . 'view.php', array('view' => 'upcoming', 'course' => $calendar->courseid));
$PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, 0, 0, 0, $time));
$PAGE->navbar->add($pagetitle);
$PAGE->set_title($course->shortname . ': ' . get_string('calendar', 'calendar') . ': ' . $pagetitle);
$PAGE->set_heading($course->fullname);
$PAGE->set_pagelayout('standard');
$renderer = $PAGE->get_renderer('core_calendar');
$calendar->add_sidecalendar_blocks($renderer);
// Get the calendar type we are using.
$calendartype = \core_calendar\type_factory::get_calendar_instance();
$now = $calendartype->timestamp_to_date_array($time);
$weekend = CALENDAR_DEFAULT_WEEKEND;
if (isset($CFG->calendar_weekend)) {
    $weekend = intval($CFG->calendar_weekend);
}
$numberofdaysinweek = $calendartype->get_num_weekdays();
$formdata = array('allownextweek' => $weekend & 1 << $now['wday'], 'allownextmonth' => calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < $numberofdaysinweek, 'allowthisweek' => !($weekend & 1 << $now['wday'] && !($weekend & 1 << ($now['wday'] + 1) % $numberofdaysinweek)));
$exportform = new core_calendar_export_form(null, $formdata);
$calendarurl = '';
if ($data = $exportform->get_data()) {
    $password = $DB->get_record('user', array('id' => $USER->id), 'password');
    $params = array();
    $params['userid'] = $USER->id;
    $params['authtoken'] = sha1($USER->id . (isset($password->password) ? $password->password : '') . $CFG->calendar_exportsalt);
    $params['preset_what'] = $data->events['exportevents'];
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:export.php


示例10: select_time

 /**
  * This is a shortcut for making an hour selector menu.
  *
  * @param string $type The type of selector (years, months, days, hours, minutes)
  * @param string $name fieldname
  * @param int $currenttime A default timestamp in GMT
  * @param int $step minute spacing
  * @param array $attributes - html select element attributes
  * @return HTML fragment
  */
 public static function select_time($type, $name, $currenttime = 0, $step = 5, array $attributes = null)
 {
     if (!$currenttime) {
         $currenttime = time();
     }
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     $currentdate = $calendartype->timestamp_to_date_array($currenttime);
     $userdatetype = $type;
     $timeunits = array();
     switch ($type) {
         case 'years':
             $timeunits = $calendartype->get_years();
             $userdatetype = 'year';
             break;
         case 'months':
             $timeunits = $calendartype->get_months();
             $userdatetype = 'month';
             $currentdate['month'] = (int) $currentdate['mon'];
             break;
         case 'days':
             $timeunits = $calendartype->get_days();
             $userdatetype = 'mday';
             break;
         case 'hours':
             for ($i = 0; $i <= 23; $i++) {
                 $timeunits[$i] = sprintf("%02d", $i);
             }
             break;
         case 'minutes':
             if ($step != 1) {
                 $currentdate['minutes'] = ceil($currentdate['minutes'] / $step) * $step;
             }
             for ($i = 0; $i <= 59; $i += $step) {
                 $timeunits[$i] = sprintf("%02d", $i);
             }
             break;
         default:
             throw new coding_exception("Time type {$type} is not supported by html_writer::select_time().");
     }
     if (empty($attributes['id'])) {
         $attributes['id'] = self::random_id('ts_');
     }
     $timerselector = self::select($timeunits, $name, $currentdate[$userdatetype], null, $attributes);
     $label = self::tag('label', get_string(substr($type, 0, -1), 'form'), array('for' => $attributes['id'], 'class' => 'accesshide'));
     return $label . $timerselector;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:56,代码来源:outputcomponents.php


示例11: select_time

    /**
     * This is a shortcut for making an hour selector menu.
     *
     * @param string $type The type of selector (years, months, days, hours, minutes)
     * @param string $name fieldname
     * @param int $currenttime A default timestamp in GMT
     * @param int $step minute spacing
     * @param array $attributes - html select element attributes
     * @return HTML fragment
     */
    public static function select_time($type, $name, $currenttime = 0, $step = 5, array $attributes = null) {
        global $OUTPUT;

        if (!$currenttime) {
            $currenttime = time();
        }
        $calendartype = \core_calendar\type_factory::get_calendar_instance();
        $currentdate = $calendartype->timestamp_to_date_array($currenttime);
        $userdatetype = $type;
        $timeunits = array();

        switch ($type) {
            case 'years':
                $timeunits = $calendartype->get_years();
                $userdatetype = 'year';
                break;
            case 'months':
                $timeunits = $calendartype->get_months();
                $userdatetype = 'month';
                $currentdate['month'] = (int)$currentdate['mon'];
                break;
            case 'days':
                $timeunits = $calendartype->get_days();
                $userdatetype = 'mday';
                break;
            case 'hours':
                for ($i=0; $i<=23; $i++) {
                    $timeunits[$i] = sprintf("%02d",$i);
                }
                break;
            case 'minutes':
                if ($step != 1) {
                    $currentdate['minutes'] = ceil($currentdate['minutes']/$step)*$step;
                }

                for ($i=0; $i<=59; $i+=$step) {
                    $timeunits[$i] = sprintf("%02d",$i);
                }
                break;
            default:
                throw new coding_exception("Time type $type is not supported by html_writer::select_time().");
        }

        $attributes = (array) $attributes;
        $data = (object) [
            'name' => $name,
            'id' => !empty($attributes['id']) ? $attributes['id'] : self::random_id('ts_'),
            'label' => get_string(substr($type, 0, -1), 'form'),
            'options' => array_map(function($value) use ($timeunits, $currentdate, $userdatetype) {
                return [
                    'name' => $timeunits[$value],
                    'value' => $value,
                    'selected' => $currentdate[$userdatetype] == $value
                ];
            }, array_keys($timeunits)),
        ];

        unset($attributes['id']);
        unset($attributes['name']);
        $data->attributes = array_map(function($name) use ($attributes) {
            return [
                'name' => $name,
                'value' => $attributes[$name]
            ];
        }, array_keys($attributes));

        return $OUTPUT->render_from_template('core/select_time', $data);
    }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:78,代码来源:outputcomponents.php


示例12: abs

            $data->startwday = abs($data->startwday % 7);
        }
        set_user_preference('calendar_startwday', $data->startwday);
        // Calendar events.
        if (intval($data->maxevents) >= 1) {
            set_user_preference('calendar_maxevents', $data->maxevents);
        }
        // Calendar lookahead.
        if (intval($data->lookahead) >= 1) {
            set_user_preference('calendar_lookahead', $data->lookahead);
        }
        set_user_preference('calendar_persistflt', intval($data->persistflt));
        // Calendar type.
        $calendartype = $data->calendartype;
        // If the specified calendar type does not exist, use the site default.
        if (!array_key_exists($calendartype, \core_calendar\type_factory::get_list_of_calendar_types())) {
            $calendartype = $CFG->calendartype;
        }
        $user->calendartype = $calendartype;
        // Update user with new calendar type.
        user_update_user($user, false, false);
        // Trigger event.
        \core\event\user_updated::create_from_userid($user->id)->trigger();
        if ($USER->id == $user->id) {
            $USER->calendartype = $calendartype;
        }
        redirect($redirect);
    }
}
// Display page header.
$streditmycalendar = get_string('calendarpreferences', 'calendar');
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:calendar.php


示例13: fill_properties_cache

 /**
  * Definition of user profile fields and the expected parameter type for data validation.
  *
  * array(
  *     'property_name' => array(       // The user property to be checked. Should match the field on the user table.
  *          'null' => NULL_ALLOWED,    // Defaults to NULL_NOT_ALLOWED. Takes NULL_NOT_ALLOWED or NULL_ALLOWED.
  *          'type' => PARAM_TYPE,      // Expected parameter type of the user field.
  *          'choices' => array(1, 2..) // An array of accepted values of the user field.
  *          'default' => $CFG->setting // An default value for the field.
  *     )
  * )
  *
  * The fields choices and default are optional.
  *
  * @return void
  */
 protected static function fill_properties_cache()
 {
     global $CFG;
     if (self::$propertiescache !== null) {
         return;
     }
     // Array of user fields properties and expected parameters.
     // Every new field on the user table should be added here otherwise it won't be validated.
     $fields = array();
     $fields['id'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['auth'] = array('type' => PARAM_AUTH, 'null' => NULL_NOT_ALLOWED);
     $fields['confirmed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['policyagreed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['deleted'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['suspended'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['mnethostid'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['username'] = array('type' => PARAM_USERNAME, 'null' => NULL_NOT_ALLOWED);
     $fields['password'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['idnumber'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['firstname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['lastname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['surname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['email'] = array('type' => PARAM_RAW_TRIMMED, 'null' => NULL_NOT_ALLOWED);
     $fields['emailstop'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['icq'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['skype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['aim'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['yahoo'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['msn'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['phone1'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['phone2'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['institution'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['department'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['address'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['city'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultcity);
     $fields['country'] = array('type' => PARAM_ALPHA, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->country, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_countries(true, true)));
     $fields['lang'] = array('type' => PARAM_LANG, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->lang, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_translations(false)));
     $fields['calendartype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->calendartype, 'choices' => array_merge(array('' => ''), \core_calendar\type_factory::get_list_of_calendar_types()));
     $fields['theme'] = array('type' => PARAM_THEME, 'null' => NULL_NOT_ALLOWED, 'default' => theme_config::DEFAULT_THEME, 'choices' => array_merge(array('' => ''), get_list_of_themes()));
     $fields['timezone'] = array('type' => PARAM_TIMEZONE, 'null' => NULL_NOT_ALLOWED, 'default' => core_date::get_server_timezone());
     // Must not use choices here: timezones can come and go.
     $fields['firstaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['currentlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastip'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['secret'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['picture'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['url'] = array('type' => PARAM_URL, 'null' => NULL_NOT_ALLOWED);
     $fields['description'] = array('type' => PARAM_RAW, 'null' => NULL_ALLOWED);
     $fields['descriptionformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['mailformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_mailformat);
     $fields['maildigest'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildigest);
     $fields['maildisplay'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildisplay);
     $fields['autosubscribe'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_autosubscribe);
     $fields['trackforums'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_trackforums);
     $fields['timecreated'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['timemodified'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['trustbitmask'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['imagealt'] = array('type' => PARAM_TEXT, 'null' => NULL_ALLOWED);
     $fields['lastnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['firstnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['middlename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['alternatename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     self::$propertiescache = $fields;
 }
开发者ID:sirromas,项目名称:lms,代码行数:82,代码来源:user.php


示例14: definition


//.........这里部分代码省略.........
         if (!in_array($course->format, $courseformats)) {
             // this format is disabled. Still display it in the dropdown
             $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_' . $course->format));
         }
     }
     $mform->addElement('select', 'format', get_string('format'), $formcourseformats);
     $mform->addHelpButton('format', 'format');
     $mform->setDefault('format', $courseconfig->format);
     // Button to update format-specific options on format change (will be hidden by JavaScript).
     $mform->registerNoSubmitButton('updatecourseformat');
     $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
     // Just a placeholder for the course format options.
     $mform->addElement('hidden', 'addcourseformatoptionshere');
     $mform->setType('addcourseformatoptionshere', PARAM_BOOL);
     // Appearance.
     $mform->addElement('header', 'appearancehdr', get_string('appearance'));
     if (!empty($CFG->allowcoursethemes)) {
         $themeobjects = get_list_of_themes();
         $themes = array();
         $themes[''] = get_string('forceno');
         foreach ($themeobjects as $key => $theme) {
             if (empty($theme->hidefromselector)) {
                 $themes[$key] = get_string('pluginname', 'theme_' . $theme->name);
             }
         }
         $mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
     }
     $languages = array();
     $languages[''] = get_string('forceno');
     $languages += get_string_manager()->get_list_of_translations();
     $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
     $mform->setDefault('lang', $courseconfig->lang);
     // Multi-Calendar Support - see MDL-18375.
     $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
     // We do not want to show this option unless there is more than one calendar type to display.
     if (count($calendartypes) > 1) {
         $calendars = array();
         $calendars[''] = get_string('forceno');
         $calendars += $calendartypes;
         $mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendars);
     }
     $options = range(0, 10);
     $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
     $mform->addHelpButton('newsitems', 'newsitemsnumber');
     $mform->setDefault('newsitems', $courseconfig->newsitems);
     $mform->addElement('selectyesno', 'showgrades', get_string('showgrades'));
     $mform->addHelpButton('showgrades', 'showgrades');
     $mform->setDefault('showgrades', $courseconfig->showgrades);
     $mform->addElement('selectyesno', 'showreports', get_string('showreports'));
     $mform->addHelpButton('showreports', 'showreports');
     $mform->setDefault('showreports', $courseconfig->showreports);
     // Files and uploads.
     $mform->addElement('header', 'filehdr', get_string('filesanduploads'));
     if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) {
         if (empty($course->legacyfiles)) {
             //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet
             $choices = array('0' => get_string('no'), '2' => get_string('yes'));
         } else {
             $choices = array('1' => get_string('no'), '2' => get_string('yes'));
         }
         $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices);
         $mform->addHelpButton('legacyfiles', 'courselegacyfiles');
         if (!isset($courseconfig->legacyfiles)) {
             // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses
             $courseconfig->legacyfiles = 0;
         }
开发者ID:educakanchay,项目名称:campus,代码行数:67,代码来源:edit_form.php


示例15: timestamp_to_date_array

 /**
  * Given a $time timestamp in GMT (seconds since epoch), returns an array that represents
  * the date in user time.
  *
  * @param int $time timestamp in GMT
  * @param float|int|string $timezone the timezone to use to calculate the time
  *        {@link http://docs.moodle.org/dev/Time_API#Timezone}
  * @return array an array that represents the date in user time
  */
 public function timestamp_to_date_array($time, $timezone = 99)
 {
     $gregoriancalendar = \core_calendar\type_factory::get_calendar_instance('gregorian');
     $date = $gregoriancalendar->timestamp_to_date_array($time, $timezone);
     $newdate = $this->convert_from_gregorian($date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes']);
     $date['year'] = $newdate['year'];
     $date['mon'] = $newdate['month'];
     $date['mday'] = $newdate['day'];
     $date['hours'] = $newdate['hour'];
     $date['minutes'] = $newdate['minute'];
     return $date;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:21,代码来源:calendartype_test_example.php


示例16: admin_externalpage

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP core_competency\api类代码示例发布时间:2022-05-23
下一篇:
PHP core_availability\info_module类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap