mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-20204 one more step away from html_select
This commit is contained in:
parent
c86a91d508
commit
2f0e96e447
8 changed files with 29 additions and 80 deletions
|
@ -177,28 +177,13 @@ if (!empty($allowedusers)) {
|
|||
}
|
||||
$contents .= $OUTPUT->select($select);
|
||||
}
|
||||
$checkbox = new html_select_option();
|
||||
$checkbox->value = 1;
|
||||
$checkbox->id = 'enablevaliduntil'.$user->id;
|
||||
$checkbox->name = 'enablevaliduntil';
|
||||
$checkbox->selected = empty($user->validuntil)?false:true;
|
||||
$checkbox->text = get_string('enabled', 'webservice');
|
||||
$checkbox->label->text = get_string('enabled', 'webservice');
|
||||
$checkbox->alt = get_string('enabled', 'webservice');
|
||||
$checkbox->add_action('change', 'external_disablevaliduntil', array($user->id)); //into admin/webservice/script.js
|
||||
$contents .= $OUTPUT->checkbox($checkbox, 'enablevaliduntil');
|
||||
$contents .= ""; //init date selector disable status
|
||||
$contents .= html_writer::checkbox('enablevaliduntil', 1, !empty($user->validuntil), get_string('enabled', 'webservice'), array('id'=>'enablevaliduntil'.$user->id));
|
||||
// TODO: init date selector using standard $PAGE->requires->js_init_call();
|
||||
|
||||
$contents .= "</div></div>";
|
||||
//TO IMPLEMENT : assign the required capability (if needed)
|
||||
$contents .= "<div class=\"fitem\"><div class=\"fitemtitle\"><label>".get_string('addrequiredcapability','webservice')." </label></div><div class=\"felement fcheckbox\">";
|
||||
$checkbox = new html_select_option();
|
||||
$checkbox->value = $user->id;
|
||||
$checkbox->selected = false;
|
||||
$checkbox->text = ' ';
|
||||
$checkbox->label->text = ' ';
|
||||
$checkbox->alt = 'TODO:'.get_string('addrequiredcapability', 'webservice');
|
||||
$contents .= $OUTPUT->checkbox($checkbox, 'addcap')."</div></div>";
|
||||
$contents .= html_writer::checkbox('addcap', 1, 'TODO:'.get_string('addrequiredcapability', 'webservice'));
|
||||
$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.'" />';
|
||||
|
|
|
@ -99,7 +99,7 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
|
||||
<tr valign="top">
|
||||
<td align="right">delete_current:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->delete_current), get_string("deletecheck", "moodle", get_string('oldpassword'))), 'delete_current');?> <br />
|
||||
<td><?php echo html_writer::checkbox('delete_current', '1', !empty($frm->delete_current), get_string("deletecheck", "moodle", get_string('oldpassword')));?> <br />
|
||||
<hr /></td>
|
||||
</tr>
|
||||
|
||||
|
@ -122,20 +122,20 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
|
||||
<tr valign="top">
|
||||
<td align="right">an_avs:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_avs), get_string("adminavs", "enrol_authorize")), 'an_avs'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('an_avs', '1', !empty($frm->an_avs), get_string("adminavs", "enrol_authorize")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_authcode:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_authcode), get_string("adminauthcode", "enrol_authorize")), 'an_authcode'); ?>
|
||||
<td><?php echo html_writer::checkbox('an_authcode', '1', !empty($frm->an_authcode), get_string("adminauthcode", "enrol_authorize")); ?>
|
||||
<?php echo $OUTPUT->help_icon('authorize/authcode', 'authcode', 'enrol'); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_test:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_test), get_string("antestmode", "enrol_authorize")), 'an_test'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('an_test', '1', !empty($frm->an_test), get_string("antestmode", "enrol_authorize")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -146,26 +146,26 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
$allpaymentmethods = get_list_of_payment_methods(true);
|
||||
foreach ($allpaymentmethods as $key) {
|
||||
if ($key == AN_METHOD_CC) {
|
||||
echo $OUTPUT->checkbox(html_select_option::make_checkbox(AN_METHOD_CC, in_array(AN_METHOD_CC, $paymentmethodsenabled), get_string('method'.AN_METHOD_CC,'enrol_authorize')), 'acceptmethods[]');
|
||||
echo html_writer::checkbox('acceptmethods[]', AN_METHOD_CC, in_array(AN_METHOD_CC, $paymentmethodsenabled), get_string('method'.AN_METHOD_CC,'enrol_authorize'));
|
||||
echo("<ul>"); // blockquote breaks <span> and <br> tags
|
||||
$acceptedccs = array_keys(get_list_of_creditcards());
|
||||
$allccs = get_list_of_creditcards(true);
|
||||
foreach ($allccs as $key => $val) {
|
||||
echo "<li>";
|
||||
echo $OUTPUT->checkbox(html_select_option::make_checkbox($key, in_array($key, $acceptedccs), $val), 'acceptccs[]');
|
||||
echo html_writer::checkbox('acceptccs[]', $key, in_array($key, $acceptedccs), $val);
|
||||
echo "</li>";
|
||||
}
|
||||
echo("</ul>");
|
||||
}
|
||||
elseif ($key == AN_METHOD_ECHECK) {
|
||||
$checkbox = html_select_option::make_checkbox(AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method'.AN_METHOD_ECHECK,'enrol_authorize'));
|
||||
$checkbox = html_writer::checkbox('enrol_authorize', AN_METHOD_ECHECK, in_array(AN_METHOD_ECHECK, $paymentmethodsenabled), get_string('method'.AN_METHOD_ECHECK));
|
||||
echo $OUTPUT->checkbox($checkbox, 'acceptmethods[]');
|
||||
echo("<ul>"); // blockquote breaks <span> and <br> tags
|
||||
$echecktypesenabled = get_list_of_bank_account_types();
|
||||
$allechecktypes = get_list_of_bank_account_types(true);
|
||||
foreach ($allechecktypes as $key) {
|
||||
echo "<li>";
|
||||
echo $OUTPUT->checkbox(html_select_option::make_checkbox($key, in_array($key, $echecktypesenabled), get_string('echeck'.strtolower($key),'enrol_authorize')), 'acceptechecktypes[]');
|
||||
echo html_writer::checkbox('acceptechecktypes[]', $key, in_array($key, $echecktypesenabled), get_string('echeck'.strtolower($key)));
|
||||
echo "</li>";
|
||||
}
|
||||
echo("</ul>");
|
||||
|
@ -180,7 +180,7 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
|
||||
<tr valign="top">
|
||||
<td align="right">an_review:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_review), get_string("adminreview", "enrol_authorize")), 'an_review'); ?>
|
||||
<td><?php echo html_writer::checkbox('an_review', '1', !empty($frm->an_review), get_string("adminreview", "enrol_authorize")); ?>
|
||||
<?php echo $OUTPUT->help_icon('authorize/review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol'); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -203,7 +203,7 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
|
||||
<tr valign="top">
|
||||
<td align="right">an_emailexpiredteacher:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->an_emailexpiredteacher), get_string("adminemailexpiredteacher", "enrol_authorize")), 'an_emailexpiredteacher'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('an_emailexpiredteacher', '1', !empty($frm->an_emailexpiredteacher), get_string("adminemailexpiredteacher", "enrol_authorize")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -220,19 +220,19 @@ if (!isset($frm->acceptechecktypes)) {
|
|||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailstudents:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->enrol_mailstudents), get_string("mailstudents")), 'enrol_mailstudents'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('enrol_mailstudents', '1', !empty($frm->enrol_mailstudents), get_string("mailstudents")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailteachers:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->enrol_mailteachers), get_string("mailteachers")), 'enrol_mailteachers'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('enrol_mailteachers', '1', !empty($frm->enrol_mailteachers), get_string("mailteachers")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailadmins:</td>
|
||||
<td><?php echo $OUTPUT->checkbox(html_select_option::make_checkbox('1', !empty($frm->enrol_mailadmins), get_string("mailadmins")), 'enrol_mailadmins'); ?><br />
|
||||
<td><?php echo html_writer::checkbox('enrol_mailadmins', '1', !empty($frm->enrol_mailadmins), get_string("mailadmins")); ?><br />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ function authorize_print_orders($courseid, $userid) {
|
|||
$popupmenu .= $OUTPUT->select(html_select::make_popup_form($baseurl.'&course='.$courseid, 'status', $statusmenu, 'statusmenu', $status));
|
||||
if ($canmanagepayments) {
|
||||
$popupmenu .= '<br />';
|
||||
$checkbox = html_select_option::make_checkbox(1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'));
|
||||
$id = html_writer::random_id('ea');
|
||||
$PAGE->requires->js('/enrol/authorize/authorize.js');
|
||||
$checkbox->add_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status));
|
||||
$popupmenu .= $OUTPUT->checkbox($checkbox, 'showonlymy');
|
||||
$OUTPUT->add_action_handler($id, new component_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status)));
|
||||
$popupmenu .= html_writer::checkbox('enrol_authorize', 1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'), array('id'=>$id));
|
||||
}
|
||||
|
||||
if (SITEID != $courseid) {
|
||||
|
@ -670,7 +670,7 @@ function authorize_print_action_button($orderid, $do, $suborderid=0, $confirm=fa
|
|||
$ret .= '<input type="hidden" name="confirm" value="1" />';
|
||||
}
|
||||
if (!empty($unenrol)) {
|
||||
$ret .= $OUTPUT->checkbox(html_select_option::make_checkbox(1, false, $unenrol), 'unenrol') . '<br />';
|
||||
$ret .= html_writer::checkbox('unenrol', 1, false, $unenrol) . '<br />';
|
||||
}
|
||||
$ret .= $extrahtml;
|
||||
$ret .= '<input type="submit" value="'.$authstrs->$do.'" />' .
|
||||
|
|
|
@ -1149,33 +1149,15 @@ class grade_edit_tree_column_select extends grade_edit_tree_column {
|
|||
}
|
||||
|
||||
public function get_item_cell($item, $params) {
|
||||
global $OUTPUT;
|
||||
if (empty($params['itemtype']) || empty($params['eid'])) {
|
||||
throw new Exception('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
|
||||
error('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
|
||||
}
|
||||
$itemselect = '';
|
||||
|
||||
if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
|
||||
$itemselect = html_select_option::make_checkbox('0', false, get_string('select'));
|
||||
$itemselect->label->add_class('accesshide');
|
||||
$itemselect->add_action('change', 'toggleCategorySelector');
|
||||
$itemselect->add_class('itemselect');
|
||||
$itemselect = $OUTPUT->checkbox($itemselect, 'select_'.$params['eid']);
|
||||
$itemselect = '<input class="itemselect" type="checkbox" name="select_'.$params['eid'].'" onchange="toggleCategorySelector();"/>'; // TODO: convert to YUI handler
|
||||
}
|
||||
/*
|
||||
if (empty($params['itemtype']) || empty($params['eid'])) {
|
||||
throw new Exception('Array key (itemtype or eid) missing from 2nd param of grade_edit_tree_column_select::get_item_cell($item, $params)');
|
||||
}
|
||||
$itemselect = '';
|
||||
|
||||
if ($params['itemtype'] != 'course' && $params['itemtype'] != 'category') {
|
||||
$itemselect = '<input class="itemselect" type="checkbox" name="select_'.$params['eid'].'" onchange="toggleCategorySelector();"/>';
|
||||
}
|
||||
*/
|
||||
$itemcell = clone($this->itemcell);
|
||||
$itemcell->add_classes(array('last', 'selection'));
|
||||
$itemcell->text = $itemselect;
|
||||
return $itemcell;
|
||||
return '<td class="cell last selection">' . $itemselect . '</td>';
|
||||
}
|
||||
|
||||
public function is_hidden($mode='simple') {
|
||||
|
|
|
@ -3434,7 +3434,7 @@ function print_checkbox($name, $value, $checked = true, $label = '', $alt = '',
|
|||
debugging('The use of the $script param in print_checkbox has not been migrated into $OUTPUT->checkbox. Please use $checkbox->add_action().', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
$output = $OUTPUT->checkbox(html_select_option::make_checkbox($value, $checked, $label, $alt), $name);
|
||||
$output = html_writer::checkbox($name, $value, $checked, $label);
|
||||
|
||||
if (empty($return)) {
|
||||
echo $output;
|
||||
|
|
|
@ -1606,24 +1606,6 @@ class html_select_option extends labelled_html_component {
|
|||
|
||||
parent::prepare($output, $page, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for making a checkbox-ready option
|
||||
* @param string $value The value of the checkbox
|
||||
* @param boolean $checked
|
||||
* @param string $label
|
||||
* @param string $alt
|
||||
* @return html_select_option A component ready for $OUTPUT->checkbox()
|
||||
*/
|
||||
public static function make_checkbox($value, $checked, $label, $alt=null) {
|
||||
$checkbox = new html_select_option();
|
||||
$checkbox->value = $value;
|
||||
$checkbox->selected = $checked;
|
||||
$checkbox->text = $label;
|
||||
$checkbox->label->text = $label;
|
||||
$checkbox->alt = $alt;
|
||||
return $checkbox;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,16 +80,16 @@ class data_field_checkbox extends data_field_base {
|
|||
$checkbox = trim($checkbox);
|
||||
|
||||
if (in_array(addslashes($checkbox), $content)) {
|
||||
$str .= $OUTPUT->checkbox(html_select_option::make_checkbox(s($checkbox), true, $checkbox), 'f_'.$this->field->id.'[]');
|
||||
$str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), true, $checkbox);
|
||||
}
|
||||
$str .= $OUTPUT->checkbox(html_select_option::make_checkbox(s($checkbox), false, $checkbox), 'f_'.$this->field->id.'[]');
|
||||
$str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), false, $checkbox);
|
||||
$found = true;
|
||||
}
|
||||
if (!$found) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$str .= $OUTPUT->checkbox(html_select_option::make_checkbox(null, false, get_string('selectedrequired', 'data')), 'f_'.$this->field->id.'_allreq');
|
||||
$str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, false, get_string('selectedrequired', 'data'));
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
|
@ -506,9 +506,9 @@ function feedback_reset_course_form($course) {
|
|||
foreach($feedbacks as $feedback) {
|
||||
echo '<p>';
|
||||
echo get_string('name','feedback').': '.$feedback->name.'<br />';
|
||||
echo $OUTPUT->checkbox(html_select_option::make_checkbox(1, true, get_string('resetting_data','feedback')), FEEDBACK_RESETFORM_RESET.$feedback->id);
|
||||
echo html_writer::checkbox(FEEDBACK_RESETFORM_RESET.$feedback->id, 1, true, get_string('resetting_data','feedback'));
|
||||
echo '<br />';
|
||||
echo $OUTPUT->checkbox(html_select_option::make_checkbox(1, false, get_string('drop_feedback','feedback')), FEEDBACK_RESETFORM_DROP.$feedback->id);
|
||||
echo html_writer::checkbox(FEEDBACK_RESETFORM_DROP.$feedback->id, 1, false, get_string('drop_feedback','feedback'));
|
||||
echo '</p>';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue