本文整理汇总了PHP中moodleform::setExpanded方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform::setExpanded方法的具体用法?PHP moodleform::setExpanded怎么用?PHP moodleform::setExpanded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodleform
的用法示例。
在下文中一共展示了moodleform::setExpanded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
$stringman = get_string_manager();
// Add the necessary names.
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
if ($stringman->string_exists('missing' . $fullname, 'core')) {
$strmissingfield = get_string('missing' . $fullname, 'core');
} else {
$strmissingfield = $strrequired;
}
$mform->addRule($fullname, $strmissingfield, '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&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', core_user::get_property_default('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', core_user::get_property_default('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', core_user::get_property_type('timezone'));
} else {
$choices = core_date::get_list_of_timezones($user->timezone, true);
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
}
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'));
$mform->setExpanded('moodle_picture', true);
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) {
//.........这里部分代码省略.........