From e357c206dbe792f805ece901d0aadf8264f5687f Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 12 Dec 2006 23:34:55 +0000 Subject: [PATCH] xhtml and accessibility cleanup in data mod MDL-7813 * image galery preset accessiblity fixes MDL-7822 * xhtml fixes * fields now use s() and p() where needed * added labels to all fields - imporved accessiblity for adding of new entries * some other general bugfixing and cleanup it is still not finished though, expect some more commits tomorrow --- mod/data/edit.php | 2 +- mod/data/field.php | 4 +- mod/data/field/checkbox/field.class.php | 16 +++--- mod/data/field/checkbox/mod.html | 14 ++--- mod/data/field/date/field.class.php | 2 +- mod/data/field/date/mod.html | 10 ++-- mod/data/field/file/field.class.php | 18 ++++--- mod/data/field/file/mod.html | 21 ++++++-- mod/data/field/latlong/field.class.php | 8 +-- mod/data/field/latlong/mod.html | 16 +++--- mod/data/field/menu/field.class.php | 4 +- mod/data/field/menu/mod.html | 14 ++--- mod/data/field/multimenu/field.class.php | 4 +- mod/data/field/multimenu/mod.html | 14 ++--- mod/data/field/number/mod.html | 10 ++-- mod/data/field/picture/field.class.php | 26 +++++----- mod/data/field/picture/mod.html | 51 ++++++++----------- mod/data/field/radiobutton/field.class.php | 14 +++-- mod/data/field/radiobutton/mod.html | 14 ++--- mod/data/field/text/mod.html | 12 ++--- mod/data/field/textarea/field.class.php | 4 +- mod/data/field/textarea/mod.html | 32 ++++++------ mod/data/field/url/field.class.php | 6 +-- mod/data/field/url/mod.html | 16 +++--- mod/data/lib.php | 36 ++++++++----- mod/data/preset.php | 4 +- mod/data/preset/imagegallery/addtemplate.html | 5 +- .../preset/imagegallery/listtemplate.html | 2 +- mod/data/templates.php | 3 ++ 29 files changed, 204 insertions(+), 178 deletions(-) diff --git a/mod/data/edit.php b/mod/data/edit.php index e811b6b900..4300bba674 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -289,7 +289,7 @@ echo $newtext; echo '
'; if ($rid) { - echo ' '; + echo ' '; } else { echo ''; } diff --git a/mod/data/field.php b/mod/data/field.php index bbfedcd2f5..2459c1cb4b 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -278,10 +278,10 @@ shorten_text($field->field->description, 30), ''. - ''.get_string('edit').''. + ''.get_string('edit').''. ' '. ''. - ''.get_string('delete').'' + ''.get_string('delete').'' ); } diff --git a/mod/data/field/checkbox/field.class.php b/mod/data/field/checkbox/field.class.php index 673433d2da..a5912ac408 100755 --- a/mod/data/field/checkbox/field.class.php +++ b/mod/data/field/checkbox/field.class.php @@ -40,26 +40,30 @@ class data_field_checkbox extends data_field_base { $content = explode('##', $content); } - $str = '
'; - + $str = '
'; + $str .= '
'.$this->field->name.''; + + $i = 0; foreach (explode("\n", $this->field->param1) as $checkbox) { $checkbox = trim($checkbox); - $str .= 'field->id.'_'.$i.'" name="field_' . $this->field->id . '[]" '; + $str .= 'value="' . s($checkbox) . '" '; if (array_search($checkbox, $content) !== false) { $str .= 'checked />'; } else { $str .= '/>'; } - $str .= $checkbox . '
'; + $str .= '
'; + $i++; } + $str .= '
'; $str .= '
'; return $str; } function update_content($recordid, $value, $name='') { - $content = new object; + $content = new object(); $content->fieldid = $this->field->id; $content->recordid = $recordid; $content->content = $this->format_data_field_checkbox_content($value); diff --git a/mod/data/field/checkbox/mod.html b/mod/data/field/checkbox/mod.html index d65576ec11..6d8bef3823 100755 --- a/mod/data/field/checkbox/mod.html +++ b/mod/data/field/checkbox/mod.html @@ -1,14 +1,14 @@ - +
- - + + - - + + - - + +
:
:
:
diff --git a/mod/data/field/date/field.class.php b/mod/data/field/date/field.class.php index 9b2824ea75..de6ac78569 100755 --- a/mod/data/field/date/field.class.php +++ b/mod/data/field/date/field.class.php @@ -42,7 +42,7 @@ class data_field_date extends data_field_base { $content = time(); } - $str = '
'; + $str = '
'; $str .= print_date_selector('field_'.$this->field->id.'_day', 'field_'.$this->field->id.'_month', 'field_'.$this->field->id.'_year', $content, true); $str .= '
'; diff --git a/mod/data/field/date/mod.html b/mod/data/field/date/mod.html index 155b409f87..831560f1b5 100755 --- a/mod/data/field/date/mod.html +++ b/mod/data/field/date/mod.html @@ -1,10 +1,10 @@ - +
- - + + - - + +
:
:
diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 5fd812f7cd..e4e2a515bb 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -60,13 +60,15 @@ class data_field_file extends data_field_base { $source = ''; } - $str = '
'; + $str = '
'; + $str .= '
'.$this->field->name.''; $str .= ''; - $str .= get_string('file','data'). ':
'; - $str .= get_string('optionalfilename','data').':
'; - $str .= ''; + $str .= get_string('file','data'). '
'; + $str .= get_string('optionalfilename','data').'
'; + $str .= ''; + $str .= '
'; $str .= '
'; if ($recordid and isset($content)){ // Print icon @@ -97,8 +99,8 @@ class data_field_file extends data_field_base { $source = $CFG->wwwroot.'/file.php?file=/'.$path; } - $width = $this->field->param1 ? ' width = "'.$this->field->param1.'" ':' '; - $height = $this->field->param2 ? ' height = "'.$this->field->param2.'" ':' '; + $width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' '; + $height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' '; require_once($CFG->libdir.'/filelib.php'); $icon = mimeinfo('icon', $src); diff --git a/mod/data/field/file/mod.html b/mod/data/field/file/mod.html index 7caf632710..9fd3c60307 100755 --- a/mod/data/field/file/mod.html +++ b/mod/data/field/file/mod.html @@ -1,10 +1,21 @@ - +
- - + + - - + + + + + +
:
:
+ maxbytes = get_field('course', 'maxbytes', 'id', $this->data->course); + $choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes); + choose_from_menu($choices, 'param3', $this->field->param3, '', '', 0, false, false, 0, 'param3'); + ?> +
diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index c44e8f4b92..6e7251c6eb 100755 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -64,11 +64,13 @@ class data_field_latlong extends data_field_base { } } - $str = '
'; + $str = '
'; + $str .= '
'.$this->field->name.''; $str .= ''; - $str .= ''; + $str .= ''; + $str .= ''; $str .= '
'; - $str .= ':°N
:°E
°N
°E
'; + $str .= '
'; $str .= '
'; return $str; diff --git a/mod/data/field/latlong/mod.html b/mod/data/field/latlong/mod.html index 4d69e4f026..d924d1104d 100755 --- a/mod/data/field/latlong/mod.html +++ b/mod/data/field/latlong/mod.html @@ -1,16 +1,16 @@ - +
- - + + - - + + - + - +
:
:
: - field->param1)); foreach($this->linkoutservices as $servicename=>$serviceurl) { @@ -22,7 +22,7 @@
: +
- - + + - - + + - - + +
:
:
:
diff --git a/mod/data/field/multimenu/field.class.php b/mod/data/field/multimenu/field.class.php index 878c64a76b..4fe8dd353e 100755 --- a/mod/data/field/multimenu/field.class.php +++ b/mod/data/field/multimenu/field.class.php @@ -40,12 +40,12 @@ class data_field_multimenu extends data_field_base { $content = array(); } - $str = '
'; + $str = '
'; $str .= ' - - + + - - + + - - + +
:
:
diff --git a/mod/data/field/number/mod.html b/mod/data/field/number/mod.html index 155b409f87..831560f1b5 100755 --- a/mod/data/field/number/mod.html +++ b/mod/data/field/number/mod.html @@ -1,10 +1,10 @@ - +
- - + + - - + +
:
:
diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 847668ac99..d4f4670596 100755 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -57,15 +57,17 @@ class data_field_picture extends data_field_file { } } - $str = '
'; + $str = '
'; + $str .= '
'.$this->field->name.''; $str .= ''; - $str .= get_string('picture','data'). ':
'; - $str .= get_string('optionaldescription','data') .':
'; - $str .= ''; + $str .= ' 
'; + $str .= ' 
'; + $str .= ''; if ($filepath){ - $str .= ''; + $str .= ''; } + $str .= '
'; $str .= '
'; return $str; } @@ -99,14 +101,14 @@ class data_field_picture extends data_field_file { } if ($template == 'listtemplate') { - $width = $this->field->param4 ? ' width="'.$this->field->param4.'" ' : ' '; - $height = $this->field->param5 ? ' height="'.$this->field->param5.'" ' : ' '; + $width = $this->field->param4 ? ' width="'.s($this->field->param4).'" ' : ' '; + $height = $this->field->param5 ? ' height="'.s($this->field->param5).'" ' : ' '; $str = ''.$alt.''; + $width.$height.' src="'.$thumbnailsource.'" alt="'.s($alt).'" title="'.s($title).'" border="0" />'; } else { - $width = $this->field->param1 ? ' width="'.$this->field->param1.'" ':' '; - $height = $this->field->param2 ? ' height="'.$this->field->param2.'" ':' '; - $str = ''.$alt.''; + $width = $this->field->param1 ? ' width="'.s($this->field->param1).'" ':' '; + $height = $this->field->param2 ? ' height="'.s($this->field->param2).'" ':' '; + $str = ''.s($alt).''; } return $str; } diff --git a/mod/data/field/picture/mod.html b/mod/data/field/picture/mod.html index 5def7328c1..66975535a2 100755 --- a/mod/data/field/picture/mod.html +++ b/mod/data/field/picture/mod.html @@ -1,60 +1,53 @@ - +
- - + - + - + - + - - + - + - + -
- : +
- : - - +
- : - - +
- : - - +
- : - +
- : - - +
- : - maxbytes = get_field('course', 'maxbytes', 'id', $this->data->course); $choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes); - choose_from_menu ($choices, "param3", $this->field->param3, ""); + choose_from_menu($choices, 'param3', $this->field->param3, '', '', 0, false, false, 0, 'param3'); ?>
diff --git a/mod/data/field/radiobutton/field.class.php b/mod/data/field/radiobutton/field.class.php index 8b670fd29d..a208898735 100755 --- a/mod/data/field/radiobutton/field.class.php +++ b/mod/data/field/radiobutton/field.class.php @@ -40,12 +40,14 @@ class data_field_radiobutton extends data_field_base { $content = ''; } - $str = '
'; - + $str = '
'; + $str .= '
'.$this->field->name.''; + + $i = 0; foreach (explode("\n",$this->field->param1) as $radio) { $radio = trim($radio); - $str .= 'field->id.'_'.$i.'" name="field_' . $this->field->id . '" '; + $str .= 'value="' . s($radio) . '" '; if ($content == $radio) { // Selected by user. @@ -54,8 +56,10 @@ class data_field_radiobutton extends data_field_base { $str .= '/>'; } - $str .= $radio . '
'; + $str .= '
'; + $i++; } + $str .= '
'; $str .= '
'; return $str; } diff --git a/mod/data/field/radiobutton/mod.html b/mod/data/field/radiobutton/mod.html index d65576ec11..6d8bef3823 100755 --- a/mod/data/field/radiobutton/mod.html +++ b/mod/data/field/radiobutton/mod.html @@ -1,14 +1,14 @@ - +
- - + + - - + + - - + +
:
:
:
diff --git a/mod/data/field/text/mod.html b/mod/data/field/text/mod.html index a39f4b83ba..940ff1cf3d 100755 --- a/mod/data/field/text/mod.html +++ b/mod/data/field/text/mod.html @@ -1,14 +1,14 @@ - +
- - + + - - + + - +
:
:
: field->param1) {echo 'checked="checked"';} ?> value="1" />
diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index d442b3969a..3d35af99de 100755 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -72,13 +72,13 @@ class data_field_textarea extends data_field_base { function gen_textarea($usehtmleditor, $text='') { return print_textarea($usehtmleditor, $this->field->param3, $this->field->param2, - '', '', 'field_'.$this->field->id, $text, '', true); + '', '', 'field_'.$this->field->id, $text, '', true, 'field_' . $this->field->id); } function print_after_form() { if (can_use_richtext_editor()) { - use_html_editor('field_' . $this->field->id); + use_html_editor('field_' . $this->field->id, '', 'field_' . $this->field->id); } } diff --git a/mod/data/field/textarea/mod.html b/mod/data/field/textarea/mod.html index 2b8c5f7776..1badc631e1 100755 --- a/mod/data/field/textarea/mod.html +++ b/mod/data/field/textarea/mod.html @@ -1,41 +1,39 @@ - +
- - + + - + - + - + diff --git a/mod/data/field/url/field.class.php b/mod/data/field/url/field.class.php index 07c5fd5502..538dcd6f3a 100755 --- a/mod/data/field/url/field.class.php +++ b/mod/data/field/url/field.class.php @@ -44,14 +44,14 @@ class data_field_url extends data_field_base { } $url = empty($url) ? 'http://' : $url; - $str = '
'; + $str = '
'; if (!empty($this->field->param1) and empty($this->field->param2)) { $str .= '
:
: + value="field->description); ?>" />
- : - - field->param2)) { - echo '"60"'; + echo('"60"'); } else { - echo('"' . $this->field->param2 . '"'); + echo '"'.s($this->field->param2).'"'; } ?> />
- : - - field->param3)) { - echo '"35"'; + echo('"35"'); } else { - echo('"' . $this->field->param3 . '"'); + echo '"'.s($this->field->param2).'"'; } ?> />
'; - $str .= ''; + $str .= ''; $str .= '
'; $str .= get_string('url','data').':
'.get_string('text','data').':
'.get_string('text','data').':
'; } else { // Just the URL field - $str .= ''; + $str .= ''; } $str .= '
'; diff --git a/mod/data/field/url/mod.html b/mod/data/field/url/mod.html index 7aa403dea4..99aadd6305 100755 --- a/mod/data/field/url/mod.html +++ b/mod/data/field/url/mod.html @@ -1,18 +1,18 @@ - +
- - + + - - + + - - + + - +
:
:
:
field->param1) {echo 'checked="checked"';} ?> value="1" />
diff --git a/mod/data/lib.php b/mod/data/lib.php index cf9f79fc35..0e3072e62a 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -198,7 +198,7 @@ class data_field_base { /// Base class for Database Field Types (see field/* echo '
'; echo ''."\n"; echo ''."\n"; - echo ''; + echo '
'; echo ''; @@ -331,12 +331,20 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa if ($fields = get_records('data_fields', 'dataid', $data->id, 'id')) { $str = '
'; - $str .= ''; + $str .= '
'; foreach ($fields as $field) { $str .= ''; $str .=''; + $str .= ''; } $str .= '
'; - $str .= $field->name.':'; + if ($template == 'addtemplate') { + $str .= 'type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) { + $str .= ' for="[['.$field->name.'#id]]"'; + } + $str .= '>'.$field->name.''; + } else { + $str .= $field->name.': '; + } $str .= ''; @@ -351,7 +359,7 @@ function data_generate_default_template(&$data, $template, $recordid=0, $form=fa } if ($template != 'addtemplate' and $template != 'rsstemplate') { //if not adding, we put tags in there - $str .= '
##Edit## ##More## ##Delete## ##Approve##
##edit## ##more## ##delete## ##approve##
'; @@ -827,35 +835,35 @@ function data_print_template($template, $records, $data, $search='',$page=0, $re } /// Replacing special tags (##Edit##, ##Delete##, ##More##) - $patterns[]='##Edit##'; - $patterns[]='##Delete##'; + $patterns[]='##edit##'; + $patterns[]='##delete##'; if (has_capability('mod/data:manageentries', $context) or data_isowner($record->id)) { $replacement[] = ''.get_string('edit').''; + .$data->id.'&rid='.$record->id.'&sesskey='.sesskey().'">'.get_string('edit').''; $replacement[] = ''.get_string('delete').''; + .$data->id.'&delete='.$record->id.'&sesskey='.sesskey().'">'.get_string('delete').''; } else { $replacement[] = ''; $replacement[] = ''; } - $patterns[]='##More##'; - $replacement[] = ''.get_string('more', 'data').''; + $patterns[]='##more##'; + $replacement[] = ''.get_string('more', 'data').''; - $patterns[]='##MoreURL##'; + $patterns[]='##moreurl##'; $replacement[] = $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$record->id; - $patterns[]='##User##'; + $patterns[]='##user##'; $replacement[] = ''.fullname($record).''; - $patterns[]='##Approve##'; + $patterns[]='##approve##'; if (has_capability('mod/data:approve', $context) && ($data->approval) && (!$record->approved)){ $replacement[] = ''.get_string('approve').''; } else { $replacement[] = ''; } - $patterns[]='##Comments##'; + $patterns[]='##comments##'; if (($template == 'listtemplate') && ($data->comments)) { $comments = count_records('data_comments','recordid',$record->id); $replacement[] = ''.get_string('commentsn','data', $comments).''; diff --git a/mod/data/preset.php b/mod/data/preset.php index 9333378a77..90e1aaa3ae 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -292,7 +292,7 @@ echo '
'; echo ''; echo ''; -echo ''; -echo '

'.$strexport.'

'; +echo '
'; helpbutton('exportzip', '', 'data'); echo ''; $options = new object(); @@ -302,7 +302,7 @@ $options->sesskey = sesskey(); print_single_button('preset.php', $options, $strexport, 'post'); echo '
'; +echo '
'; helpbutton('savepreset', '', 'data'); echo ''; $options = new object(); diff --git a/mod/data/preset/imagegallery/addtemplate.html b/mod/data/preset/imagegallery/addtemplate.html index 17088c9041..69ae28e8fd 100644 --- a/mod/data/preset/imagegallery/addtemplate.html +++ b/mod/data/preset/imagegallery/addtemplate.html @@ -1,8 +1,7 @@
- +
+
[[title]]
[[caption]]
[[image]]
-
-[[image]]
\ No newline at end of file diff --git a/mod/data/preset/imagegallery/listtemplate.html b/mod/data/preset/imagegallery/listtemplate.html index 9ff4101817..73737e1b1f 100644 --- a/mod/data/preset/imagegallery/listtemplate.html +++ b/mod/data/preset/imagegallery/listtemplate.html @@ -1,7 +1,7 @@
- +
[[image]]
[[image]]
##edit## ##delete## ##approve##
diff --git a/mod/data/templates.php b/mod/data/templates.php index 914b4321c1..c79e1d6bfe 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -208,6 +208,9 @@ if ($mode == 'addtemplate') { echo ''; foreach ($fields as $field) { + if (in_array($field->type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) { + continue; //ids are not usable for these composed items + } echo ''; } echo ''; -- 2.39.5