Skip to content

Commit

Permalink
MDL-34563 accessibility compliance for data module: Add forform input…
Browse files Browse the repository at this point in the history
… text and select tag
  • Loading branch information
Rossiani Wijaya committed Aug 13, 2012
1 parent 87e9331 commit 01f8e80
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 18 deletions.
1 change: 1 addition & 0 deletions mod/data/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@

$options = array(0 => get_string('ascending', 'data'),
1 => get_string('descending', 'data'));
echo html_writer::label(get_string('sortby'), 'menudefaultsortdir', false, array('class' => 'accesshide'));
echo html_writer::select($options, 'defaultsortdir', $data->defaultsortdir, false);
echo '<input type="submit" value="'.get_string('save', 'data').'" />';
echo '</div>';
Expand Down
14 changes: 10 additions & 4 deletions mod/data/field/date/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ function display_add_field($recordid=0) {
}

$str = '<div title="'.s($this->field->description).'">';
$dayselector = html_writer::select_time('days', 'field_'.$this->field->id.'_day', $content);
$monthselector = html_writer::select_time('months', 'field_'.$this->field->id.'_month', $content);
$yearselector = html_writer::select_time('years', 'field_'.$this->field->id.'_year', $content);
$dayselector = html_writer::label(get_string('day'), 'menufield_'.$this->field->id.'_day', false, array('class' => 'accesshide'))
. html_writer::select_time('days', 'field_'.$this->field->id.'_day', $content);
$monthselector = html_writer::label(get_string('month'), 'menufield_'.$this->field->id.'_month', false, array('class' => 'accesshide'))
. html_writer::select_time('months', 'field_'.$this->field->id.'_month', $content);
$yearselector = html_writer::label(get_string('year'), 'menufield_'.$this->field->id.'_year', false, array('class' => 'accesshide'))
. html_writer::select_time('years', 'field_'.$this->field->id.'_year', $content);
$str .= $dayselector . $monthselector . $yearselector;
$str .= '</div>';

Expand All @@ -55,8 +58,11 @@ function display_add_field($recordid=0) {

//Enable the following three functions once core API issues have been addressed.
function display_search_field($value=0) {
$selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value)
$selectors = html_writer::label(get_string('day'), 'menuf_'.$this->field->id.'_d', false, array('class' => 'accesshide'))
. html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value)
. html_writer::label(get_string('month'), 'menuf_'.$this->field->id.'_m', false, array('class' => 'accesshide'))
. html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value)
. html_writer::label(get_string('year'), 'menuf_'.$this->field->id.'_y', false, array('class' => 'accesshide'))
. html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value);
return $selectors;

Expand Down
3 changes: 2 additions & 1 deletion mod/data/field/file/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function display_add_field($recordid=0) {
}

function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for=f_"' . $this->field->id . '">' . $this->field->name . '</label>' .
'<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function generate_sql($tablealias, $value) {
Expand Down
1 change: 1 addition & 0 deletions mod/data/field/file/mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<?php
$course = $DB->get_record('course', array('id'=>$this->data->course));
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
echo html_writer::label($this->field->param3, 'menuparam3', false, array('class' => 'accesshide'));
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id' => 'param3'));
?>
</td>
Expand Down
8 changes: 6 additions & 2 deletions mod/data/field/latlong/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ function display_search_field($value = '') {
}
$latlongsrs->close();

return html_writer::select($options, 'f_'.$this->field->id, $value);
$return = html_writer::label(get_string('latlong', 'data'), 'menuf_'.$this->field->id, false, array('class' => 'accesshide'));
$return .= html_writer::select($options, 'f_'.$this->field->id, $value);
return $return;
}

function parse_search_field() {
Expand Down Expand Up @@ -150,7 +152,9 @@ function display_browse_field($recordid, $template) {
. str_replace(array_keys($urlreplacements), array_values($urlreplacements), $this->linkoutservices[$servicesshown[0]])
."' title='$servicesshown[0]'>$compasslat, $compasslong</a>";
} elseif (sizeof($servicesshown)>1) {
$str .= "$compasslat, $compasslong\n<select name='jumpto'>";
$str .= "$compasslat, $compasslong\n";
$str .= "<label class='accesshide' for='jumpto'>". get_string('jumpto') ."</label>";
$str .= "<select id='jumpto' name='jumpto'>";
foreach($servicesshown as $servicename){
// Add a link to a service
$str .= "\n <option value='"
Expand Down
6 changes: 4 additions & 2 deletions mod/data/field/menu/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function display_add_field($recordid=0) {
}
}


$str .= html_writer::label(get_string('menuchoose', 'data'), 'field_'.$this->field->id, false, array('class' => 'accesshide'));
$str .= html_writer::select($options, 'field_'.$this->field->id, $content, array(''=>get_string('menuchoose', 'data')), array('id'=>'field_'.$this->field->id));

$str .= '</div>';
Expand Down Expand Up @@ -86,7 +86,9 @@ function display_search_field($content = '') {
return '';
}

return html_writer::select($options, 'f_'.$this->field->id, $content);
$return = html_writer::label(get_string('namemenu', 'data'), 'menuf_'. $this->field->id, false, array('class' => 'accesshide'));
$return .= html_writer::select($options, 'f_'.$this->field->id, $content);
return $return;
}

function parse_search_field() {
Expand Down
4 changes: 3 additions & 1 deletion mod/data/field/multimenu/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function display_add_field($recordid=0) {

$str = '<div title="'.s($this->field->description).'">';
$str .= '<input name="field_' . $this->field->id . '[xxx]" type="hidden" value="xxx"/>'; // hidden field - needed for empty selection
$str .= '<label class="accesshide" for="field_' . $this->field->id . '">' . $this->field->name. ': </label>';
$str .= '<select name="field_' . $this->field->id . '[]" id="field_' . $this->field->id . '" multiple="multiple">';

foreach (explode("\n",$this->field->param1) as $option) {
Expand Down Expand Up @@ -71,7 +72,8 @@ function display_search_field($value = '') {

static $c = 0;

$str = '<select name="f_'.$this->field->id.'[]" multiple="multiple">';
$str = '<label class="accesshide" for="f_' . $this->field->id . '">' . $this->field->name . '</label>';
$str .= '<select id="f_'.$this->field->id.'" name="f_'.$this->field->id.'[]" multiple="multiple">';

// display only used options
$varcharcontent = $DB->sql_compare_text('content', 255);
Expand Down
3 changes: 2 additions & 1 deletion mod/data/field/number/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function display_browse_field($recordid, $template) {
}

function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
'<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function parse_search_field() {
Expand Down
3 changes: 2 additions & 1 deletion mod/data/field/picture/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function get_file($recordid, $content=null) {
}

function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
'<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function parse_search_field() {
Expand Down
1 change: 1 addition & 0 deletions mod/data/field/picture/mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<?php
$course = $DB->get_record('course', array('id'=>$this->data->course));
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
echo html_writer::label($this->field->param3, 'menuparam3', false, array('class' => 'accesshide'));
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id'=>'param3'));
?>
</td>
Expand Down
4 changes: 3 additions & 1 deletion mod/data/field/radiobutton/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ function display_search_field($value = '') {
$options[$rec->content] = $rec->content; //Build following indicies from the sql.
}
}
return html_writer::select($options, 'f_'.$this->field->id, $value);
$return = html_writer::label(get_string('nameradiobutton', 'data'), 'menuf_'. $this->field->id, false, array('class' => 'accesshide'));
$return .= html_writer::select($options, 'f_'.$this->field->id, $value);
return $return;
}

function parse_search_field() {
Expand Down
2 changes: 1 addition & 1 deletion mod/data/field/text/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class data_field_text extends data_field_base {
var $type = 'text';

function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for="f_' . $this->field->id . '">'. $this->field->name.'</label>' . '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function parse_search_field() {
Expand Down
6 changes: 4 additions & 2 deletions mod/data/field/textarea/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ function display_add_field($recordid=0) {
$editor->use_editor($field, $options, $fpoptions);
$str .= '<input type="hidden" name="'.$field.'_itemid" value="'.$draftitemid.'" />';
$str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'">'.s($text).'</textarea></div>';
$str .= '<div><select name="'.$field.'_content1">';
$str .= '<div><label class="accesshide" for="' . $field . '_content1">' . get_string('format') . '</label>';
$str .= '<select id="' . $field . '_content1" name="'.$field.'_content1">';
foreach ($formats as $key=>$desc) {
$selected = ($format == $key) ? 'selected="selected"' : '';
$str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
Expand All @@ -140,7 +141,8 @@ function display_add_field($recordid=0) {


function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for="f_' . $this->field->id . '">' . $this->field->name . '</label>' .
'<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function parse_search_field() {
Expand Down
8 changes: 6 additions & 2 deletions mod/data/field/url/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ function display_add_field($recordid=0) {
$str = '<div title="'.s($this->field->description).'">';
if (!empty($this->field->param1) and empty($this->field->param2)) {
$str .= '<table><tr><td align="right">';
$str .= get_string('url','data').':</td><td><input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.$url.'" size="60" /></td></tr>';
$str .= get_string('url','data').':</td><td>';
$str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>';
$str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.$url.'" size="60" /></td></tr>';
$str .= '<tr><td align="right">'.get_string('text','data').':</td><td><input type="text" name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="'.s($text).'" size="60" /></td></tr>';
$str .= '</table>';
} else {
// Just the URL field
$str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>';
$str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.s($url).'" size="60" />';
}

Expand All @@ -74,7 +77,8 @@ function display_add_field($recordid=0) {
}

function display_search_field($value = '') {
return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
'<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}

function parse_search_field() {
Expand Down

0 comments on commit 01f8e80

Please sign in to comment.