當前位置: 首頁>>代碼示例>>PHP>>正文


PHP moodleform類代碼示例

本文整理匯總了PHP中moodleform的典型用法代碼示例。如果您正苦於以下問題:PHP moodleform類的具體用法?PHP moodleform怎麽用?PHP moodleform使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了moodleform類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform) {
    global $CFG, $DB;
    require_once("$CFG->libdir/gdlib.php");

    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    // This will hold the value to set to the user's picture field at the end of
    // this function
    $picturetouse = null;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon'); // drop all areas
        $picturetouse = 0;
    } else if ($iconfile = $userform->save_temp_file('imagefile')) {
        // There is a new image that has been uploaded
        // Process the new image and set the user to make use of it.
        // NOTE: This may be overridden by Gravatar
        if (process_new_icon($context, 'user', 'icon', 0, $iconfile)) {
            $picturetouse = 1;
        }
        // Delete the file that has now been processed
        @unlink($iconfile);
    }

    // If we have a picture to set we can now do so. Note this will still be NULL
    // unless the user has changed their picture or caused a change by selecting
    // to delete their picture or use gravatar
    if (!is_null($picturetouse)) {
        $DB->set_field('user', 'picture', $picturetouse, array('id' => $usernew->id));
        return true;
    }

    return false;
}
開發者ID:nigeldaley,項目名稱:moodle,代碼行數:43,代碼來源:editlib.php

示例3: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data used to set default values of the form
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_role[' . $data->id . ']', $this->get_title($data));
     if ($this->id) {
         $mform->setDefault('criteria_role[' . $data->id . ']', 1);
     }
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:13,代碼來源:completion_criteria_role.php

示例4: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data Form data
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_self', get_string('enable'));
     if ($this->id) {
         $mform->setDefault('criteria_self', 1);
     }
 }
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:13,代碼來源:completion_criteria_self.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: render_stepsdefinitions

 /**
  * Renders the list of available steps according to the submitted filters
  *
  * @param string     $stepsdefinitions HTML from behat with the available steps
  * @param moodleform $form
  * @return string HTML code
  */
 public function render_stepsdefinitions($stepsdefinitions, $form)
 {
     $title = get_string('pluginname', 'tool_behat');
     // Header.
     $html = $this->output->header();
     $html .= $this->output->heading($title);
     // Info.
     $installurl = behat_command::DOCS_URL . '#Installation';
     $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank'));
     $writetestsurl = behat_command::DOCS_URL . '#Writting_features';
     $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank'));
     $writestepsurl = behat_command::DOCS_URL . '#Adding_steps_definitions';
     $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank'));
     $infos = array(get_string('installinfo', 'tool_behat', $installlink), get_string('newtestsinfo', 'tool_behat', $writetestslink), get_string('newstepsinfo', 'tool_behat', $writestepslink));
     // List of steps
     $html .= $this->output->box_start();
     $html .= html_writer::tag('h1', 'Info');
     $html .= html_writer::empty_tag('div');
     $html .= html_writer::empty_tag('ul');
     $html .= html_writer::empty_tag('li');
     $html .= implode(html_writer::end_tag('li') . html_writer::empty_tag('li'), $infos);
     $html .= html_writer::end_tag('li');
     $html .= html_writer::end_tag('ul');
     $html .= html_writer::end_tag('div');
     $html .= $this->output->box_end();
     // Form.
     ob_start();
     $form->display();
     $html .= ob_get_contents();
     ob_end_clean();
     // Steps definitions.
     $html .= html_writer::tag('div', $stepsdefinitions, array('class' => 'steps-definitions'));
     $html .= $this->output->footer();
     return $html;
 }
開發者ID:Burick,項目名稱:moodle,代碼行數:42,代碼來源:renderer.php

示例7: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform Moodle forms object
  * @param stdClass $data Form data
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_unenrol', get_string('completiononunenrolment', 'completion'));
     if ($this->id) {
         $mform->setDefault('criteria_unenrol', 1);
     }
 }
開發者ID:JP-Git,項目名稱:moodle,代碼行數:13,代碼來源:completion_criteria_unenrol.php

示例8: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data details of various modules
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', ucfirst(self::get_mod_name($data->module)) . ' - ' . $data->name);
     if ($this->id) {
         $mform->setDefault('criteria_activity[' . $data->id . ']', 1);
     }
 }
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:13,代碼來源:completion_criteria_activity.php

示例9: useredit_update_picture

/**
 * Updates the provided users profile picture based upon the expected fields
 * returned from the edit or edit_advanced forms.
 *
 * @global moodle_database $DB
 * @param stdClass $usernew An object that contains some information about the user being updated
 * @param moodleform $userform The form that was submitted to edit the form
 * @return bool True if the user was updated, false if it stayed the same.
 */
function useredit_update_picture(stdClass $usernew, moodleform $userform)
{
    global $CFG, $DB;
    require_once "{$CFG->libdir}/gdlib.php";
    $context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
    $user = $DB->get_record('user', array('id' => $usernew->id), 'id, picture', MUST_EXIST);
    $newpicture = $user->picture;
    if (!empty($usernew->deletepicture)) {
        // The user has chosen to delete the selected users picture
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user', 'icon');
        // drop all images in area
        $newpicture = 0;
    } else {
        if ($iconfile = $userform->save_temp_file('imagefile')) {
            // There is a new image that has been uploaded
            // Process the new image and set the user to make use of it.
            // NOTE: Uploaded images always take over Gravatar
            $newpicture = (int) process_new_icon($context, 'user', 'icon', 0, $iconfile);
            // Delete the file that has now been processed
            @unlink($iconfile);
        }
    }
    if ($newpicture != $user->picture) {
        $DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
        return true;
    } else {
        return false;
    }
}
開發者ID:nmicha,項目名稱:moodle,代碼行數:39,代碼來源:editlib.php

示例10: capability_form

 /**
  * Render a formslib form.
  * @param moodleform $form
  * @return string the HTML to output.
  */
 protected function capability_form(moodleform $form)
 {
     ob_start();
     $form->display();
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
開發者ID:Keneth1212,項目名稱:moodle,代碼行數:13,代碼來源:renderer.php

示例11: setupForm

 /**
  * Adds controls specific to this filter in the form.
  * @param moodleform $mform a MoodleForm object to setup
  */
 public function setupForm(&$mform)
 {
     $choices = array('' => get_string('anyvalue', 'filters')) + $this->_options;
     $mform->addElement('select', $this->_name, $this->_label, $choices);
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name);
     }
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:12,代碼來源:simpleselect.php

示例12: moodleform

 /**
  * Use this since we can't fetch the output of a moodle form
  * @param moodleform $mform
  * @return type string HTML
  */
 protected function moodleform(moodleform $mform)
 {
     ob_start();
     $mform->display();
     $o = ob_get_contents();
     ob_end_clean();
     return $o;
 }
開發者ID:nateyb93,項目名稱:upad-createcourse,代碼行數:13,代碼來源:renderer.php

示例13: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodleform $mform  Moodle forms object
  * @param stdClass $data details of various modules
  */
 public function config_form_display(&$mform, $data = null)
 {
     $modnames = get_module_types_names();
     $mform->addElement('checkbox', 'criteria_activity[' . $data->id . ']', $modnames[self::get_mod_name($data->module)] . ' - ' . format_string($data->name));
     if ($this->id) {
         $mform->setDefault('criteria_activity[' . $data->id . ']', 1);
     }
 }
開發者ID:Gavinthisisit,項目名稱:Moodle,代碼行數:14,代碼來源:completion_criteria_activity.php

示例14:

 /**
  * 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

示例15: 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


注:本文中的moodleform類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。