Skip to content

Commit

Permalink
MDL-20204 more outputlib changes towards separate html_writer
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 7, 2010
1 parent ab8b514 commit 916276f
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 262 deletions.
30 changes: 14 additions & 16 deletions admin/webservice/service_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

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));
Expand Down Expand Up @@ -160,21 +161,11 @@

//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\">";
Expand Down Expand Up @@ -208,8 +199,15 @@
$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);

Expand Down
15 changes: 8 additions & 7 deletions blocks/blog_menu/block_blog_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function get_content() {
$output = '';

$this->content = new stdClass;
$this->content->footer = '';

$blogheaders = blog_get_headers();
$canviewblogs = has_capability('moodle/blog:view', $context);
Expand Down Expand Up @@ -121,12 +120,14 @@ function get_content() {

// 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);
Expand Down
18 changes: 8 additions & 10 deletions blocks/settings_navigation_tree/block_settings_navigation_tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@ function get_content() {
// 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 = '';
}
Expand Down
96 changes: 24 additions & 72 deletions grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,31 +358,18 @@ function get_weight_input($item, $type) {
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 '';
}
Expand Down Expand Up @@ -799,10 +786,7 @@ public function get_item_cell($item, $params) {
} 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);
Expand Down Expand Up @@ -836,26 +820,17 @@ public function get_header_cell() {
}

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');
}

$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregateonlygraded;
$categorycell->text = $hidden.$aggregateonlygraded;
return $categorycell;
}

Expand All @@ -882,25 +857,17 @@ public function get_header_cell() {
}

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');
}

$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregatesubcats;
$categorycell->text = $hidden.$aggregatesubcats;
return $categorycell;

}
Expand Down Expand Up @@ -928,25 +895,17 @@ public function get_header_cell() {
}

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');
}

$categorycell = clone($this->categorycell);
$categorycell->add_class($levelclass);
$categorycell->text = $OUTPUT->field($hidden).$aggregateoutcomes;
$categorycell->text = $hidden.$aggregateoutcomes;
return $categorycell;
}

Expand Down Expand Up @@ -980,10 +939,7 @@ public function get_header_cell() {
}

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;
Expand Down Expand Up @@ -1016,10 +972,7 @@ public function get_header_cell() {
}

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;
Expand Down Expand Up @@ -1067,10 +1020,9 @@ public function get_item_cell($item, $params) {
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;
}

Expand Down Expand Up @@ -1110,9 +1062,9 @@ public function get_item_cell($item, $params) {
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;

}
Expand Down
13 changes: 8 additions & 5 deletions grade/report/grader/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,14 @@

// 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;
}
Expand Down
21 changes: 12 additions & 9 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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).');

global $OUTPUT;
if ($al === '') {
$alt = null;
}

$field = html_field::make_text($name, $value, $alt, $maxlength);
$field->style = "width: {$size}px;";
$style = "width: {$size}px;";
$attributes = array('type'=>'text', 'name'=>$name, 'alt'=>$alt, 'style'=>$style, 'value'=>$value);
if ($maxlength) {
$attributes['maxlength'] = $maxlength;
}

$output = $OUTPUT->textfield($field);
$output = html_writer::empty_tag('input', $attributes);

if (empty($return)) {
echo $output;
} else {
return $output;
}

}


Expand Down
Loading

0 comments on commit 916276f

Please sign in to comment.