MDL-20204 more outputlib changes towards separate html_writer

This commit is contained in:
Petr Skoda 2010-02-07 20:12:31 +00:00
parent ab8b51424c
commit 916276fc0a
11 changed files with 96 additions and 262 deletions

View File

@ -41,7 +41,8 @@ $PAGE->requires->js('/admin/webservice/script.js');
admin_externalpage_setup('externalserviceusers');
admin_externalpage_print_header();
global $DB;
/// Get the user_selector we will need.
$potentialuserselector = new service_user_selector('addselect', array('serviceid' => $id, 'displayallowedusers' => 0));
$alloweduserselector = new service_user_selector('removeselect', array('serviceid' => $id, 'displayallowedusers' => 1));
@ -160,21 +161,11 @@ if (!empty($allowedusers)) {
//user settings form
$contents = "<div class=\"fcontainer clearfix\">";
$form = new html_form();
$form->url = new moodle_url('service_users.php', array('id' => $id, 'userid' => $user->id, 'updateuser' => 1, 'serviceuserid' => $user->serviceuserid)); // Required
$form->button = new html_button();
$form->button->text = get_string('update'); // Required
$form->button->disabled = false;
$form->button->title = get_string('update');
$form->method = 'post';
$form->id = 'usersetting'.$user->id;
//ip restriction textfield
$contents .= "<div class=\"fitem\"><div class=\"fitemtitle\"><label>".get_string('iprestriction','webservice')." </label></div><div class=\"felement\">";
$field = new html_field();
$field->name = 'iprestriction';
$field->value = $user->iprestriction;
$field->style = 'width: 30em;';
$contents .= $OUTPUT->textfield($field);
$iprestid = 'iprest'.$user->id;
$contents .= "<div class=\"fitem\"><div class=\"fitemtitle\"><label for=\"$iprestid\">".get_string('iprestriction','webservice')." </label></div><div class=\"felement\">";
$contents .= '<input type="text" id="'.$iprestid.'" name="iprestriction" style="width: 30em;" value="'.s($user->iprestriction).'" />';
$contents .= "</div></div>";
//valid until date selector
$contents .= "<div class=\"fitem\"><div class=\"fitemtitle\"><label>".get_string('validuntil','webservice')." </label></div><div class=\"felement\">";
@ -208,8 +199,15 @@ if (!empty($allowedusers)) {
$checkbox->label->text = ' ';
$checkbox->alt = 'TODO:'.get_string('addrequiredcapability', 'webservice');
$contents .= $OUTPUT->checkbox($checkbox, 'addcap')."</div></div>";
$contents .= '<div><input type="submit" name="submit" value="'.s(get_string('update')).'" /></div>';
$contents .= '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
$contents .= '<input type="hidden" name="id" value="'.$id.'" />';
$contents .= '<input type="hidden" name="userid" value="'.$user->id.'" />';
$contents .= '<input type="hidden" name="serviceuserid" value="'.$user->serviceuserid.'" />';
$contents .= '<input type="hidden" name="updateuser" value="1" />';
$contents .= "</div>";
echo $OUTPUT->form($form, $contents);
echo html_writer::tag('form', array('target'=>'service_users.php', 'method'=>'post', 'id'=>'usersetting'.$user->id), $contents);
echo print_collapsible_region_end(true);

View File

@ -68,7 +68,6 @@ class block_blog_menu extends block_base {
$output = '';
$this->content = new stdClass;
$this->content->footer = '';
$blogheaders = blog_get_headers();
$canviewblogs = has_capability('moodle/blog:view', $context);
@ -121,12 +120,14 @@ class block_blog_menu extends block_base {
// Full-text search field
if (has_capability('moodle/blog:search', $sitecontext)) {
$searchform = new html_form();
$searchform->method = 'get';
$searchform->url = new moodle_url($blogheaders['url']);
$searchform->button->text = get_string('search');
$formcontents = $OUTPUT->field(html_field::make_text('search', '', '', 99));
$menulist->add_item($OUTPUT->form($searchform, $formcontents));
$target = new moodle_url($blogheaders['url']);
$form = '<form class="blogsearchform" method="get" action="'.$target.'">';
$form .= '<div><label for="blogsearchquery" class="accesshide">'.s(get_string('search', 'admin')).'</label><input id="blogsearchquery" type="text" name="search" />';
$form .= '<input type="submit" value="'.s(get_string('search')).'" />';
$form .= '</div></form>';
$this->content->footer = $form;
} else {
$this->content->footer = '';
}
$this->content->text = $OUTPUT->htmllist($menulist);

View File

@ -130,16 +130,14 @@ class block_settings_navigation_tree extends block_tree {
// only do search if you have moodle/site:config
if (count($this->content->items)>0) {
if (has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) ) {
$searchform = new html_form();
$searchform->url = new moodle_url("$CFG->wwwroot/$CFG->admin/search.php");
$searchform->method = 'get';
$searchform->button->text = get_string('search');
$searchfield = html_field::make_text('query', optional_param('query', '', PARAM_RAW), '', 50);
$searchfield->id = 'query';
$searchfield->style .= 'width: 7em;';
$searchfield->set_label(get_string('searchinsettings', 'admin'), 'query');
$searchfield->label->add_class('accesshide');
$this->content->footer = $OUTPUT->container($OUTPUT->form($searchform, $OUTPUT->field($searchfield)), 'adminsearchform');
$value = optional_param('query', '', PARAM_RAW);
$target = new moodle_url("$CFG->wwwroot/$CFG->admin/search.php");
$form = '<form class="adminsearchform" method="get" action="'.$target.'">';
$form .= '<div><label for="adminsearchquery" class="accesshide">'.s(get_string('searchinsettings', 'admin')).'</label>';
$form .= '<input id="adminsearchquery" type="text" name="query" value="'.s($value).'"/>';
$form .= '<input type="submit" value="'.s(get_string('search')).'" />';
$form .= '</div></form>';
$this->content->footer = $form;
} else {
$this->content->footer = '';
}

View File

@ -358,31 +358,18 @@ class grade_edit_tree {
return '';
}
$weightfield = new html_field();
$parent_category = $item->get_parent_category();
$parent_category->apply_forced_settings();
$aggcoef = $item->get_coefstring();
if ((($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoef') && $type == 'weight') ||
($aggcoef == 'aggregationcoefextra' && $type == 'extra')) {
$weightfield->type = 'text';
$weightfield->id = "aggregationcoef_$item->id";
$weightfield->name = "aggregationcoef_$item->id";
$weightfield->value = format_float($item->aggregationcoef, 4);
return $OUTPUT->field($weightfield);;
return '<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'"
value="'.format_float($item->aggregationcoef, 4).'" />';
} elseif ($aggcoef == 'aggregationcoefextrasum' && $type == 'extra') {
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
$weightfield->type = 'hidden';
$weightfield->name = "extracredit_$item->id";
$weightfield->value = 0;
$extracredit = html_select_option::make_checkbox(1, ($item->aggregationcoef > 0), get_string($aggcoef, 'grades'));
$extracredit->label->add_class('accesshide');
$extracredit->id = "extracredit_$item->id";
$extracredit->name = "extracredit_$item->id";
return $OUTPUT->field($weightfield) . $OUTPUT->checkbox($extracredit);
return '<input type="hidden" name="extracredit_'.$item->id.'" value="0" />
<input type="checkbox" id="extracredit_'.$item->id.'" name="extracredit_'.$item->id.'" value="1" '."$checked />\n";
} else {
return '';
}
@ -799,10 +786,7 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
} elseif ($item->is_external_item()) {
$grademax = format_float($item->grademax, $item->get_decimals());
} else {
$grademaxinput = html_field::make_text("grademax_$item->id", format_float($item->grademax, $item->get_decimals()), get_string('grademax', 'grades'));
$grademaxinput->id = "grademax_$item->id";
$grademaxinput->title = get_string('grademax', 'grades');
$grademax = $OUTPUT->field($grademaxinput);
$grademax = '<input type="text" size="4" id="grademax'.$item->id.'" name="grademax_'.$item->id.'" value="'.format_float($item->grademax, $item->get_decimals()).'" />';
}
$itemcell = clone($this->itemcell);
@ -836,18 +820,9 @@ class grade_edit_tree_column_aggregateonlygraded extends grade_edit_tree_column_
}
public function get_category_cell($category, $levelclass, $params) {
global $OUTPUT;
$hidden = new html_field();
$hidden->type = 'hidden';
$hidden->name = "aggregateonlygraded_$category->id";
$hidden->value = 0;
$aggregateonlygraded = html_select_option::make_checkbox(1, ($category->aggregateonlygraded == 1), get_string('aggregateonlygraded', 'grades'));
$aggregateonlygraded->label->add_class('accesshide');
$aggregateonlygraded->id = "aggregateonlygraded_$category->id";
$aggregateonlygraded->name = "aggregateonlygraded_$category->id";
$aggregateonlygraded = $OUTPUT->checkbox($aggregateonlygraded);
$onlygradedcheck = ($category->aggregateonlygraded == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregateonlygraded_'.$category->id.'" value="0" />';
$aggregateonlygraded ='<input type="checkbox" id="aggregateonlygraded_'.$category->id.'" name="aggregateonlygraded_'.$category->id.'" value="1" '.$onlygradedcheck . ' />';
if ($this->forced) {
$aggregateonlygraded = ($category->aggregateonlygraded) ? get_string('yes') : get_string('no');
@ -855,7 +830,7 @@ class grade_edit_tree_column_aggregateonlygraded extends grade_edit_tree_column_
$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregateonlygraded;
$categorycell->text = $hidden.$aggregateonlygraded;
return $categorycell;
}
@ -882,17 +857,9 @@ class grade_edit_tree_column_aggregatesubcats extends grade_edit_tree_column_cat
}
public function get_category_cell($category, $levelclass, $params) {
global $OUTPUT;
$hidden = new html_field();
$hidden->type = 'hidden';
$hidden->name = "aggregatesubcats_$category->id";
$hidden->value = 0;
$aggregatesubcats = html_select_option::make_checkbox(1, ($category->aggregatesubcats == 1), get_string('aggregatesubcats', 'grades'));
$aggregatesubcats->label->add_class('accesshide');
$aggregatesubcats->id = "aggregatesubcats_$category->id";
$aggregatesubcats->name = "aggregatesubcats_$category->id";
$aggregatesubcats = $OUTPUT->checkbox($aggregatesubcats);
$subcatscheck = ($category->aggregatesubcats == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregatesubcats_'.$category->id.'" value="0" />';
$aggregatesubcats = '<input type="checkbox" id="aggregatesubcats_'.$category->id.'" name="aggregatesubcats_'.$category->id.'" value="1" ' . $subcatscheck.' />';
if ($this->forced) {
$aggregatesubcats = ($category->aggregatesubcats) ? get_string('yes') : get_string('no');
@ -900,7 +867,7 @@ class grade_edit_tree_column_aggregatesubcats extends grade_edit_tree_column_cat
$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregatesubcats;
$categorycell->text = $hidden.$aggregatesubcats;
return $categorycell;
}
@ -928,17 +895,9 @@ class grade_edit_tree_column_aggregateoutcomes extends grade_edit_tree_column_ca
}
public function get_category_cell($category, $levelclass, $params) {
global $OUTPUT;
$hidden = new html_field();
$hidden->type = 'hidden';
$hidden->name = "aggregateoutcomes_$category->id";
$hidden->value = 0;
$aggregateoutcomes = html_select_option::make_checkbox(1, ($category->aggregateoutcomes == 1), get_string('aggregateoutcomes', 'grades'));
$aggregateoutcomes->label->add_class('accesshide');
$aggregateoutcomes->id = "aggregateoutcomes_$category->id";
$aggregateoutcomes->name = "aggregateoutcomes_$category->id";
$aggregateoutcomes = $OUTPUT->checkbox($aggregateoutcomes);
$outcomescheck = ($category->aggregateoutcomes == 1) ? 'checked="checked"' : '';
$hidden = '<input type="hidden" name="aggregateoutcomes_'.$category->id.'" value="0" />';
$aggregateoutcomes = '<input type="checkbox" id="aggregateoutcomes_'.$category->id.'" name="aggregateoutcomes_'.$category->id.'" value="1" ' . $outcomescheck.' />';
if ($this->forced) {
$aggregateoutcomes = ($category->aggregateoutcomes) ? get_string('yes') : get_string('no');
@ -946,7 +905,7 @@ class grade_edit_tree_column_aggregateoutcomes extends grade_edit_tree_column_ca
$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregateoutcomes;
$categorycell->text = $hidden.$aggregateoutcomes;
return $categorycell;
}
@ -980,10 +939,7 @@ class grade_edit_tree_column_droplow extends grade_edit_tree_column_category {
}
public function get_category_cell($category, $levelclass, $params) {
global $OUTPUT;
$droplowinput = html_field::make_text("droplow_$category->id", $category->droplow, get_string('droplow', 'grades'));
$droplowinput->id = $droplowinput->name;
$droplow = $OUTPUT->field($droplowinput);
$droplow = '<input type="text" size="3" id="droplow_'.$category->id.'" name="droplow_'.$category->id.'" value="'.$category->droplow.'" />';
if ($this->forced) {
$droplow = $category->droplow;
@ -1016,10 +972,7 @@ class grade_edit_tree_column_keephigh extends grade_edit_tree_column_category {
}
public function get_category_cell($category, $levelclass, $params) {
global $OUTPUT;
$keephighinput = html_field::make_text("keephigh_$category->id", $category->keephigh, get_string('keephigh', 'grades'));
$keephighinput->id = $keephighinput->name;
$keephigh = $OUTPUT->field($keephighinput);
$keephigh = '<input type="text" size="3" id="keephigh_'.$category->id.'" name="keephigh_'.$category->id.'" value="'.$category->keephigh.'" />';
if ($this->forced) {
$keephigh = $category->keephigh;
@ -1067,10 +1020,9 @@ class grade_edit_tree_column_multfactor extends grade_edit_tree_column {
return $itemcell;
}
$multfactorinput = html_field::make_text("multfactor_$item->id", format_float($item->multfactor, 4), get_string('multfactor', 'grades'));
$multfactorinput->id = $multfactorinput->name;
$multfactor = '<input type="text" size="4" id="multfactor'.$item->id.'" name="multfactor_'.$item->id.'" value="'.format_float($item->multfactor, 4).'" />';
$itemcell->text = $OUTPUT->field($multfactorinput);
$itemcell->text = $multfactorinput;
return $itemcell;
}
@ -1110,9 +1062,9 @@ class grade_edit_tree_column_plusfactor extends grade_edit_tree_column {
return $itemcell;
}
$plusfactorinput = html_field::make_text("plusfactor_$item->id", format_float($item->plusfactor, 4), get_string('plusfactor', 'grades'));
$plusfactorinput->id = $plusfactorinput->name;
$itemcell->text = $OUTPUT->field($plusfactorinput);
$plusfactor = '<input type="text" size="4" id="plusfactor_'.$item->id.'" name="plusfactor_'.$item->id.'" value="'.format_float($item->plusfactor, 4).'" />';
$itemcell->text = $plusfactorinput;
return $itemcell;
}

View File

@ -173,11 +173,14 @@ $reporthtml = $report->get_grade_table();
// print submit button
if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading')) && !$report->get_pref('enableajax')) {
$form = new html_form();
$form->url = new moodle_url('index.php', array('id' => $courseid, 'report' => 'grader'));
$form->button->text = get_string('update');
$form->button->add_class('submit');
echo $OUTPUT->form($form, $reporthtml);
echo '<form action="index.php" method="post">';
echo '<div>';
echo '<input type="hidden" value="'.s($courseid).'" name="id" />';
echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
echo '<input type="hidden" value="grader" name="report"/>';
echo $reporthtml;
echo '<div class="submit"><input type="submit" value="'.s(get_string('update')).'" /></div>';
echo '</div></form>';
} else {
echo $reporthtml;
}

View File

@ -3425,7 +3425,7 @@ function choose_from_radio ($options, $name, $checked='', $return=false) {
* it (defaults to false)
* @return string|void If $return=true returns string, else echo's and returns void
*/
function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '', $script='',$return=false) {
function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) {
// debugging('print_checkbox() has been deprecated. Please change your code to use $OUTPUT->checkbox($checkbox).');
global $OUTPUT;
@ -3459,23 +3459,26 @@ function print_checkbox ($name, $value, $checked = true, $label = '', $alt = '',
* it (defaults to false)
* @return string|void If $return=true returns string, else echo's and returns void
*/
function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $return=false) {
function print_textfield($name, $value, $alt = '', $size=50, $maxlength=0, $return=false) {
debugging('print_textfield() has been deprecated. Please use mforms or html_writer.');
debugging('print_textfield() has been deprecated. Please change your code to use $OUTPUT->textfield($field).');
if ($al === '') {
$alt = null;
}
global $OUTPUT;
$style = "width: {$size}px;";
$attributes = array('type'=>'text', 'name'=>$name, 'alt'=>$alt, 'style'=>$style, 'value'=>$value);
if ($maxlength) {
$attributes['maxlength'] = $maxlength;
}
$field = html_field::make_text($name, $value, $alt, $maxlength);
$field->style = "width: {$size}px;";
$output = $OUTPUT->textfield($field);
$output = html_writer::empty_tag('input', $attributes);
if (empty($return)) {
echo $output;
} else {
return $output;
}
}

View File

@ -1510,76 +1510,6 @@ class html_select_optgroup extends html_component {
}
/**
* This class represents an input field
*
* @copyright 2009 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class html_field extends labelled_html_component {
/**
* @var string $name The name attribute of the field
*/
public $name;
/**
* @var string $value The value attribute of the field
*/
public $value;
/**
* @var string $type The type attribute of the field (text, submit, checkbox etc)
*/
public $type;
/**
* @var string $maxlength The maxlength attribute of the field (only applies to text type)
*/
public $maxlength;
/**
* @var boolean $disabled Whether or not this field is disabled
*/
public $disabled = false;
public function __construct() {
$this->label = new html_label();
}
/**
* @see html_component::prepare()
* @return void
*/
public function prepare(renderer_base $output, moodle_page $page, $target) {
if (empty($this->style)) {
$this->style = 'width: 4em;';
}
if (empty($this->id)) {
$this->generate_id();
}
parent::prepare($output, $page, $target);
}
/**
* Shortcut for creating a text input component.
* @param string $name The name of the text field
* @param string $value The value of the text field
* @param string $alt The info to be inserted in the alt tag
* @param int $maxlength Sets the maxlength attribute of the field. Not set by default
* @return html_field The field component
*/
public static function make_text($name='unnamed', $value='', $alt=null, $maxlength=0) {
$field = new html_field();
if (empty($alt)) {
$alt = $name;
}
$field->type = 'text';
$field->name = $name;
$field->value = $value;
$field->alt = $alt;
$field->maxlength = $maxlength;
return $field;
}
}
/**
* Holds all the information required to render a <table> by
* {@see core_renderer::table()} or by an overridden version of that

View File

@ -1844,42 +1844,6 @@ class core_renderer extends renderer_base {
}
}
/**
* Output an <input type="text"> element
*
* @param html_field $field a html_field object
* @return string the HTML for the <input>
*/
public function textfield($field) {
return html_writer::tag('span', array('class' => "textfield $field->name"), $this->field($field));
}
/**
* Output an <input/> element
*
* @param html_field $field a html_field object
* @return string the HTML for the <input>
*/
public function field($field) {
$field = clone($field);
$field->prepare($this, $this->page, $this->target);
$this->prepare_event_handlers($field);
$label = '';
if (!empty($field->label->text)) {
$label = $this->label($field->label);
}
return $label . html_writer::empty_tag('input', array(
'type' => $field->type,
'name' => $field->name,
'id' => $field->id,
'value' => $field->value,
'disabled' => $field->disabled ? 'disabled' : null,
'style' => $field->style,
'alt' => $field->alt,
'title' => $field->title,
'maxlength' => $field->maxlength));
}
/**
* Outputs a <label> element.
* @param html_label $label A html_label object

View File

@ -170,20 +170,22 @@ echo $result->feedback;
// User is modifying attempts - save button and some instructions
if (isset($USER->modattempts[$lesson->id])) {
$url = $CFG->wwwroot.'/mod/lesson/view.php';
$options = array('id'=>$cm->id, 'pageid'=>LESSON_EOL);
$form = html_form::make($url, $options, get_string('savechanges', 'lesson'));
$content = $OUTPUT->box(get_string("savechangesandeol", "lesson"), 'center');
$content .= $OUTPUT->box(get_string("or", "lesson"), 'center');
$content .= $OUTPUT->box(get_string("continuetoanswer", "lesson"), 'center');
echo $OUTPUT->form($form, $content);
$content .= html_writer::empty_tag('input', array('type'=>'hidden', 'nam'=>'id', 'value'=>$cm->id));
$content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>LESSON_EOL));
$content .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'submit', 'value'=>get_string('savechanges', 'lesson')));
echo html_writer::tag('form', array('method'=>'get', 'target'=>$url), "<div>$content</div>");
}
// Review button back
if ($lesson->review && !$result->correctanswer && !$result->noanswer && !$result->isessayquestion) {
$url = $CFG->wwwroot.'/mod/lesson/view.php';
$options = array('id'=>$cm->id, 'pageid'=>$page->id);
$form = html_form::make($url, $options, get_string('reviewquestionback', 'lesson'));
echo $OUTPUT->form($form);
$content = html_writer::empty_tag('input', array('type'=>'hidden', 'nam'=>'id', 'value'=>$cm->id));
$content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>$page->id));
$content .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'submit', 'value'=>get_string('reviewquestionback', 'lesson')));
echo html_writer::tag('form', array('method'=>'get', 'target'=>$url), "<div>$content</div>");
}
$url = new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'pageid'=>$result->newpageid));

View File

@ -137,7 +137,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
/**
* Returns HTML to display a message
* @param string $message
* @param html_form $button
* @param single_button $button
* @return string
*/
public function message($message, single_button $button = null) {

View File

@ -292,7 +292,6 @@ EOF;
/// Print button
$form = new html_form();
$authparams['print'] = true;
//$parameters = array ('token' => $token, 'wsusername' => $username, 'wspassword' => $password, 'print' => true);
$url = new moodle_url('/webservice/wsdoc.php', $authparams); // Required
@ -465,38 +464,22 @@ EOF;
// $htmlloginpage .= html_writer::empty_tag('br', array());
//login form - we cannot use moodle form as we don't have sessionkey
$form = new html_form();
$form->url = new moodle_url('/webservice/wsdoc.php', array()); // Required
$form->button = new html_button();
$form->button->text = get_string('wsdocumentation','webservice'); // Required
$form->button->disabled = false;
$form->button->title = get_string('wsdocumentation','webservice');
$form->method = 'post';
$target = new moodle_url('/webservice/wsdoc.php', array()); // Required
$contents =get_string('entertoken', 'webservice');
$contents .=$br.$br;
$field = new html_field();
$field->name = 'token';
$field->style = 'width: 30em;';
$contents .= $OUTPUT->textfield($field);
$contents .=$br.$br;
$contents .=get_string('wsdocumentationlogin', 'webservice');
$contents .=$br.$br;
$field = new html_field();
$field->name = 'wsusername';
$field->value = get_string('wsusername', 'webservice');
$field->style = 'width: 30em;';
$contents .= $OUTPUT->textfield($field);
$contents = get_string('entertoken', 'webservice');
$contents .= $br.$br;
$field = new html_field();
$field->name = 'wspassword';
$field->value = get_string('wspassword', 'webservice');
$field->style = 'width: 30em;';
$contents .= $OUTPUT->textfield($field);
$contents .=$br.$br;
$contents .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>'token', 'style'=>'width: 30em;'));
$htmlloginpage .= $OUTPUT->form($form, $contents);
$contents .= $br.$br;
$contents .= get_string('wsdocumentationlogin', 'webservice');
$contents .= $br.$br;
$contents .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>'wsusername', 'style'=>'width: 30em;', 'value'=>get_string('wsusername', 'webservice')));
$contents .= $br.$br;
$contents .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>'wspassword', 'style'=>'width: 30em;', 'value'=>get_string('wspassword', 'webservice')));
$contents .= $br.$br;
$contents .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'submit', 'value'=>get_string('wsdocumentation', 'webservice')));
$htmlloginpage .= html_writer::tag('form', array('method'=>'post', 'target'=>$target), "<div>$contents</div>");
$htmlloginpage .= html_writer::end_tag('td');
$htmlloginpage .= html_writer::end_tag('tr');