本文整理汇总了PHP中moodleform类的典型用法代码示例。如果您正苦于以下问题:PHP moodleform类的具体用法?PHP moodleform怎么用?PHP moodleform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodleform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: render_course_enrolment_users_table
public function render_course_enrolment_users_table(course_enrolment_users_table $table, moodleform $mform)
{
$table->initialise_javascript();
// Added for the Bootstrap theme. Make this table responsive.
$table->attributes['class'] .= ' table table-responsive';
$buttons = $table->get_manual_enrol_buttons();
$buttonhtml = '';
if (count($buttons) > 0) {
$buttonhtml .= html_writer::start_tag('div', array('class' => 'enrol_user_buttons'));
foreach ($buttons as $button) {
$buttonhtml .= $this->render($button);
}
$buttonhtml .= html_writer::end_tag('div');
}
$content = '';
if (!empty($buttonhtml)) {
$content .= $buttonhtml;
}
$content .= $mform->render();
$content .= $this->output->render($table->get_paging_bar());
// Check if the table has any bulk operations. If it does we want to wrap the table in a
// form so that we can capture and perform any required bulk operations.
if ($table->has_bulk_user_enrolment_operations()) {
$content .= html_writer::start_tag('form', array('action' => new moodle_url('/enrol/bulkchange.php'), 'method' => 'post'));
foreach ($table->get_combined_url_params() as $key => $value) {
if ($key == 'action') {
continue;
}
$content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
$content .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'bulkchange'));
$content .= html_writer::table($table);
$content .= html_writer::start_tag('div', array('class' => 'singleselect bulkuserop'));
$content .= html_writer::start_tag('select', array('name' => 'bulkuserop'));
$content .= html_writer::tag('option', get_string('withselectedusers', 'enrol'), array('value' => ''));
$options = array('' => get_string('withselectedusers', 'enrol'));
foreach ($table->get_bulk_user_enrolment_operations() as $operation) {
$content .= html_writer::tag('option', $operation->get_title(), array('value' => $operation->get_identifier()));
}
$content .= html_writer::end_tag('select');
$content .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('go')));
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('form');
} else {
// Added for the Bootstrap theme, a no-overflow wrapper.
$content .= html_writer::start_tag('div', array('class' => 'no-overflow'));
$content .= html_writer::table($table);
$content .= html_writer::end_tag('div');
}
$content .= $this->output->render($table->get_paging_bar());
if (!empty($buttonhtml)) {
$content .= $buttonhtml;
}
return $content;
}
开发者ID:adonm,项目名称:learning,代码行数:55,代码来源:enrol_renderer.php
示例17: render_stepsdefinitions
/**
* Renders the list of available steps according to the submitted filters.
*
* @param mixed $stepsdefinitions Available steps array.
* @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', get_string('infoheading', 'tool_behat'));
$html .= html_writer::tag('div', get_string('aim', 'tool_behat'));
$html .= html_writer::start_tag('div');
$html .= html_writer::start_tag('ul');
$html .= html_writer::start_tag('li');
$html .= implode(html_writer::end_tag('li') . html_writer::start_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();
if (empty($stepsdefinitions)) {
$stepsdefinitions = get_string('nostepsdefinitions', 'tool_behat');
} else {
$stepsdefinitions = implode('', $stepsdefinitions);
// Replace text selector type arguments with a user-friendly select.
$stepsdefinitions = preg_replace_callback('/(TEXT_SELECTOR\\d?_STRING)/', function ($matches) {
return html_writer::select(behat_selectors::get_allowed_text_selectors(), uniqid());
}, $stepsdefinitions);
// Replace selector type arguments with a user-friendly select.
$stepsdefinitions = preg_replace_callback('/(SELECTOR\\d?_STRING)/', function ($matches) {
return html_writer::select(behat_selectors::get_allowed_selectors(), uniqid());
}, $stepsdefinitions);
// Replace simple OR options.
$regex = '#\\(\\?P<[^>]+>([^\\)|]+\\|[^\\)]+)\\)#';
$stepsdefinitions = preg_replace_callback($regex, function ($matches) {
return html_writer::select(explode('|', $matches[1]), uniqid());
}, $stepsdefinitions);
}
// Steps definitions.
$html .= html_writer::tag('div', $stepsdefinitions, array('class' => 'steps-definitions'));
$html .= $this->output->footer();
return $html;
}
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:61,代码来源:renderer.php
示例18: 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
示例19: setupForm
/**
* Adds controls specific to this filter in the form.
*
* @param moodleform $mform a MoodleQuickForm object in which element will be added
*/
public function setupForm(&$mform)
{
$mform->addElement('checkbox', $this->_name, $this->_label, '');
if ($this->_advanced) {
$mform->setAdvanced($this->_name);
}
// Check if disable if options are set. if yes then set rules.
if (!empty($this->disableelements) && is_array($this->disableelements)) {
foreach ($this->disableelements as $disableelement) {
$mform->disabledIf($disableelement, $this->_name, 'checked');
}
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:checkbox.php
示例20: config_form_display
/**
* Add appropriate form elements to the critieria form
*
* @param moodleform $mform Moodle forms object
* @param stdClass $data not used
*/
public function config_form_display(&$mform, $data = null)
{
$mform->addElement('checkbox', 'criteria_duration', get_string('enable'));
$thresholdmenu = array();
for ($i = 1; $i <= 30; $i++) {
$seconds = $i * 86400;
$thresholdmenu[$seconds] = get_string('numdays', '', $i);
}
$mform->addElement('select', 'criteria_duration_days', get_string('daysafterenrolment', 'completion'), $thresholdmenu);
if ($this->id) {
$mform->setDefault('criteria_duration', 1);
$mform->setDefault('criteria_duration_days', $this->enrolperiod);
}
}
开发者ID:nmicha,项目名称:moodle,代码行数:20,代码来源:completion_criteria_duration.php
注:本文中的moodleform类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论