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


PHP moodleform::setType方法代码示例

本文整理汇总了PHP中moodleform::setType方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform::setType方法的具体用法?PHP moodleform::setType怎么用?PHP moodleform::setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodleform的用法示例。


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

示例1: define_form_specific

 /**
  * Define the setting for a datetime custom field.
  *
  * @param moodleform $form the user form
  */
 public function define_form_specific($form)
 {
     // Get the current calendar in use - see MDL-18375.
     $calendartype = \core_calendar\type_factory::get_calendar_instance();
     // Create variables to store start and end.
     list($year, $month, $day) = explode('_', date('Y_m_d'));
     $currentdate = $calendartype->convert_from_gregorian($year, $month, $day);
     $currentyear = $currentdate['year'];
     $arryears = $calendartype->get_years();
     // Add elements.
     $form->addElement('select', 'param1', get_string('startyear', 'profilefield_datetime'), $arryears);
     $form->setType('param1', PARAM_INT);
     $form->setDefault('param1', $currentyear);
     $form->addElement('select', 'param2', get_string('endyear', 'profilefield_datetime'), $arryears);
     $form->setType('param2', PARAM_INT);
     $form->setDefault('param2', $currentyear);
     $form->addElement('checkbox', 'param3', get_string('wanttime', 'profilefield_datetime'));
     $form->setType('param3', PARAM_INT);
     $form->addElement('hidden', 'startday', '1');
     $form->setType('startday', PARAM_INT);
     $form->addElement('hidden', 'startmonth', '1');
     $form->setType('startmonth', PARAM_INT);
     $form->addElement('hidden', 'startyear', '1');
     $form->setType('startyear', PARAM_INT);
     $form->addElement('hidden', 'endday', '1');
     $form->setType('endday', PARAM_INT);
     $form->addElement('hidden', 'endmonth', '1');
     $form->setType('endmonth', PARAM_INT);
     $form->addElement('hidden', 'endyear', '1');
     $form->setType('endyear', PARAM_INT);
     $form->addElement('hidden', 'defaultdata', '0');
     $form->setType('defaultdata', PARAM_INT);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:38,代码来源:define.class.php

示例2: define_form_specific

 /**
  * Adds elements to the form for creating/editing this type of profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Param 1 for menu type contains the options.
     $form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
     $form->setType('param1', PARAM_TEXT);
     // Default data.
     $form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
     $form->setType('defaultdata', PARAM_TEXT);
 }
开发者ID:krysnuvadga,项目名称:moodle,代码行数:13,代码来源:define.class.php

示例3: specific_definition

 /**
  * Form definition.
  *
  * @param moodleform $mform Moodle form.
  * @return void
  */
 protected function specific_definition($mform)
 {
     $mform->addElement('header', 'confighdr', get_string('configheader', 'block_xp'));
     $mform->addElement('text', 'config_title', get_string('configtitle', 'block_xp'));
     $mform->setDefault('config_title', get_string('levelup', 'block_xp'));
     $mform->setType('config_title', PARAM_TEXT);
     $mform->addElement('textarea', 'config_description', get_string('configdescription', 'block_xp'));
     $mform->setDefault('config_description', get_string('participatetolevelup', 'block_xp'));
     $mform->setType('config_description', PARAM_TEXT);
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:16,代码来源:edit_form.php

示例4: edit_field_add

 /**
  * Adds elements for this field type to the edit form.
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Create the form field.
     $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null);
     $mform->setType($this->inputname, PARAM_RAW);
     // We MUST clean this before display!
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:field.class.php

示例5: define_form_specific

 /**
  * Add elements for creating/editing a textarea profile field.
  * @param moodleform $form
  */
 public function define_form_specific($form)
 {
     // Default data.
     $form->addElement('editor', 'defaultdata', get_string('profiledefaultdata', 'admin'));
     $form->setType('defaultdata', PARAM_RAW);
     // We have to trust person with capability to edit this default description.
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:define.class.php

示例6:

 /**
  * Prints out the form snippet for the part of creating or
  * editing a profile field specific to the current data type
  *
  * @param moodleform $form reference to moodleform for adding elements.
  */
 function define_form_specific(&$form)
 {
     //Add elements, set defualt value and define type of data
     $form->addElement('radio', 'defaultdata', get_string('mystring', 'profilefield_myprofilefield'));
     $form->setDefault('defaultdata', 1);
     // defaults to 'yes'
     $form->setType('defaultdata', PARAM_BOOL);
 }
开发者ID:dariogs,项目名称:moosh,代码行数:14,代码来源:define.class.php

示例7: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $objs = array();
     $objs[] = $mform->createElement('select', $this->_name . '_rl', null, $this->get_roles());
     $objs[] = $mform->createElement('select', $this->_name . '_ct', null, $this->get_course_categories());
     $objs[] = $mform->createElement('text', $this->_name, null);
     $grp =& $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->setType($this->_name, PARAM_TEXT);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:courserole.php

示例8: edit_field_add

 /**
  * Add elements for editing the profile field value.
  * @param moodleform $mform
  */
 public function edit_field_add($mform)
 {
     // Create the form field.
     $checkbox = $mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
     if ($this->data == '1') {
         $checkbox->setChecked(true);
     }
     $mform->setType($this->inputname, PARAM_BOOL);
     if ($this->is_required() and !has_capability('moodle/user:update', context_system::instance())) {
         $mform->addRule($this->inputname, get_string('required'), 'nonzero', null, 'client');
     }
 }
开发者ID:janeklb,项目名称:moodle,代码行数:16,代码来源:field.class.php

示例9: define_form_common

 /**
  * Prints out the form snippet for the part of creating or editing a profile field common to all data types.
  *
  * @param moodleform $form instance of the moodleform class
  */
 public function define_form_common(&$form)
 {
     $strrequired = get_string('required');
     $form->addElement('text', 'shortname', get_string('profileshortname', 'admin'), 'maxlength="100" size="25"');
     $form->addRule('shortname', $strrequired, 'required', null, 'client');
     $form->setType('shortname', PARAM_ALPHANUM);
     $form->addElement('text', 'name', get_string('profilename', 'admin'), 'size="50"');
     $form->addRule('name', $strrequired, 'required', null, 'client');
     $form->setType('name', PARAM_TEXT);
     $form->addElement('editor', 'description', get_string('profiledescription', 'admin'), null, null);
     $form->addElement('selectyesno', 'required', get_string('profilerequired', 'admin'));
     $form->addElement('selectyesno', 'locked', get_string('profilelocked', 'admin'));
     $form->addElement('selectyesno', 'forceunique', get_string('profileforceunique', 'admin'));
     $form->addElement('selectyesno', 'signup', get_string('profilesignup', 'admin'));
     $choices = array();
     $choices[PROFILE_VISIBLE_NONE] = get_string('profilevisiblenone', 'admin');
     $choices[PROFILE_VISIBLE_PRIVATE] = get_string('profilevisibleprivate', 'admin');
     $choices[PROFILE_VISIBLE_ALL] = get_string('profilevisibleall', 'admin');
     $form->addElement('select', 'visible', get_string('profilevisible', 'admin'), $choices);
     $form->addHelpButton('visible', 'profilevisible', 'admin');
     $form->setDefault('visible', PROFILE_VISIBLE_ALL);
     $choices = profile_list_categories();
     $form->addElement('select', 'categoryid', get_string('profilecategory', 'admin'), $choices);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:29,代码来源:definelib.php

示例10: instance_config_form

    /**
     * Add Instance settings input to Moodle form
     *
     * @param moodleform $mform
     */
    public static function instance_config_form($mform) {
        $mform->addElement('text', 'equella_url', get_string('equellaurl', 'repository_equella'));
        $mform->setType('equella_url', PARAM_URL);

        $strrequired = get_string('required');
        $mform->addRule('equella_url', $strrequired, 'required', null, 'client');

        $mform->addElement('text', 'equella_options', get_string('equellaoptions', 'repository_equella'));
        $mform->setType('equella_options', PARAM_NOTAGS);

        $choices = array(
            'none' => get_string('restrictionnone', 'repository_equella'),
            'itemonly' => get_string('restrictionitemsonly', 'repository_equella'),
            'attachmentonly' => get_string('restrictionattachmentsonly', 'repository_equella'),
        );
        $mform->addElement('select', 'equella_select_restriction', get_string('selectrestriction', 'repository_equella'), $choices);

        $mform->addElement('header', '',
            get_string('group', 'repository_equella', get_string('groupdefault', 'repository_equella')));
        $mform->addElement('text', 'equella_shareid', get_string('sharedid', 'repository_equella'));
        $mform->setType('equella_shareid', PARAM_RAW);
        $mform->addRule('equella_shareid', $strrequired, 'required', null, 'client');

        $mform->addElement('text', 'equella_sharedsecret', get_string('sharedsecrets', 'repository_equella'));
        $mform->setType('equella_sharedsecret', PARAM_RAW);
        $mform->addRule('equella_sharedsecret', $strrequired, 'required', null, 'client');

        foreach (self::get_all_editing_roles() as $role) {
            $mform->addElement('header', '', get_string('group', 'repository_equella', format_string($role->name)));
            $mform->addElement('text', "equella_{$role->shortname}_shareid", get_string('sharedid', 'repository_equella'));
            $mform->setType("equella_{$role->shortname}_shareid", PARAM_RAW);
            $mform->addElement('text', "equella_{$role->shortname}_sharedsecret",
                get_string('sharedsecrets', 'repository_equella'));
            $mform->setType("equella_{$role->shortname}_sharedsecret", PARAM_RAW);
        }
    }
开发者ID:Burick,项目名称:moodle,代码行数:41,代码来源:lib.php

示例11: 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&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', 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) {
//.........这里部分代码省略.........
开发者ID:gabrielrosset,项目名称:moodle,代码行数:101,代码来源:editlib.php

示例12: get_pattern_import_settings

 /**
  * Returns import settings for the specified field pattern
  * that consist of a list of mform elements to group, and
  * a list of corresponding labels.
  * By default adds the specified pattern name. Subclasses can override
  * to exclude patterns from import or deny import at all.
  *
  * @param moodleform $mform
  * @param string $patternname
  * @param string $header The default value of the name element
  * @return array
  */
 public function get_pattern_import_settings(&$mform, $patternname, $header)
 {
     $field = $this->_field;
     $fieldid = $field->id;
     $fieldname = $field->name;
     $patternpart = trim(str_replace($fieldname, '', $patternname), ':');
     $name = "f_{$fieldid}_{$patternpart}";
     $grp = array();
     $grp[] =& $mform->createElement('text', "{$name}_name", null, array('size' => '16'));
     $mform->setType("{$name}_name", PARAM_TEXT);
     $mform->setDefault("{$name}_name", $header);
     return array($grp, array());
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:25,代码来源:dataformfieldrenderer.php

示例13: useredit_shared_definition_preferences

/**
 * Adds user preferences elements to user edit form.
 *
 * @param stdClass $user
 * @param moodleform $mform
 * @param array|null $editoroptions
 * @param array|null $filemanageroptions
 */
function useredit_shared_definition_preferences($user, &$mform, $editoroptions = null, $filemanageroptions = null)
{
    global $CFG;
    $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);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
    $mform->addHelpButton('maildigest', 'emaildigest');
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
    }
    $editors = editors_get_enabled();
    if (count($editors) > 1) {
        $choices = array('' => get_string('defaulteditor'));
        $firsteditor = '';
        foreach (array_keys($editors) as $editor) {
            if (!$firsteditor) {
                $firsteditor = $editor;
            }
            $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
        }
        $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('preference_htmleditor', '');
    } else {
        // Empty string means use the first chosen text editor.
        $mform->addElement('hidden', 'preference_htmleditor');
        $mform->setDefault('preference_htmleditor', '');
        $mform->setType('preference_htmleditor', PARAM_PLUGIN);
    }
    $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
    $mform->setDefault('lang', $CFG->lang);
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:73,代码来源:editlib.php

示例14: useredit_shared_definition

/**
 * Powerful function that is used by edit and editadvanced to add common form elements/rules/etc.
 *
 * @param moodleform $mform
 * @param array|null $editoroptions
 * @param array|null $filemanageroptions
 */
function useredit_shared_definition(&$mform, $editoroptions = null, $filemanageroptions = null)
{
    global $CFG, $USER, $DB;
    $user = $DB->get_record('user', array('id' => $USER->id));
    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 (!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_EMAIL);
    }
    $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', 2);
    $choices = array();
    $choices['0'] = get_string('textformat');
    $choices['1'] = get_string('htmlformat');
    $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
    $mform->setDefault('mailformat', 1);
    if (!empty($CFG->allowusermailcharset)) {
        $choices = array();
        $charsets = get_list_of_charsets();
        if (!empty($CFG->sitemailcharset)) {
            $choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
        } else {
            $choices['0'] = get_string('site') . ' (UTF-8)';
        }
        $choices = array_merge($choices, $charsets);
        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
    }
    $choices = array();
    $choices['0'] = get_string('emaildigestoff');
    $choices['1'] = get_string('emaildigestcomplete');
    $choices['2'] = get_string('emaildigestsubjects');
    $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
    $mform->setDefault('maildigest', 0);
    $mform->addHelpButton('maildigest', 'emaildigest');
    $choices = array();
    $choices['1'] = get_string('autosubscribeyes');
    $choices['0'] = get_string('autosubscribeno');
    $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
    $mform->setDefault('autosubscribe', 1);
    if (!empty($CFG->forum_trackreadposts)) {
        $choices = array();
        $choices['0'] = get_string('trackforumsno');
        $choices['1'] = get_string('trackforumsyes');
        $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
        $mform->setDefault('trackforums', 0);
    }
    $editors = editors_get_enabled();
    if (count($editors) > 1) {
        $choices = array('' => get_string('defaulteditor'));
        $firsteditor = '';
        foreach (array_keys($editors) as $editor) {
            if (!$firsteditor) {
                $firsteditor = $editor;
            }
            $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
        }
        $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
        $mform->setDefault('preference_htmleditor', '');
    } else {
        // Empty string means use the first chosen text editor.
        $mform->addElement('hidden', 'preference_htmleditor');
        $mform->setDefault('preference_htmleditor', '');
        $mform->setType('preference_htmleditor', PARAM_PLUGIN);
    }
    $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();
//.........这里部分代码省略.........
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:101,代码来源:editlib.php

示例15: instance_config_form

 /**
  * Edit/Create Instance Settings Moodle form
  *
  * @param moodleform $mform Moodle form (passed by reference)
  */
 public static function instance_config_form($mform)
 {
     global $CFG;
     if (has_capability('moodle/site:config', context_system::instance())) {
         $path = $CFG->dataroot . '/repository/';
         if (!is_dir($path)) {
             mkdir($path, $CFG->directorypermissions, true);
         }
         if ($handle = opendir($path)) {
             $fieldname = get_string('path', 'repository_filesystem');
             $choices = array();
             while (false !== ($file = readdir($handle))) {
                 if (is_dir($path . $file) && $file != '.' && $file != '..') {
                     $choices[$file] = $file;
                     $fieldname = '';
                 }
             }
             if (empty($choices)) {
                 $mform->addElement('static', '', '', get_string('nosubdir', 'repository_filesystem', $path));
                 $mform->addElement('hidden', 'fs_path', '');
                 $mform->setType('fs_path', PARAM_PATH);
             } else {
                 $mform->addElement('select', 'fs_path', $fieldname, $choices);
                 $mform->addElement('static', null, '', get_string('information', 'repository_filesystem', $path));
             }
             closedir($handle);
         }
         $mform->addElement('checkbox', 'relativefiles', get_string('relativefiles', 'repository_filesystem'), get_string('relativefiles_desc', 'repository_filesystem'));
         $mform->setType('relativefiles', PARAM_INT);
     } else {
         $mform->addElement('static', null, '', get_string('nopermissions', 'error', get_string('configplugin', 'repository_filesystem')));
         return false;
     }
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:39,代码来源:lib.php


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