本文整理汇总了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!
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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.
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}