]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11436, Encapsulate "accesshide" HTML class in function.
authornfreear <nfreear>
Tue, 25 Sep 2007 11:33:30 +0000 (11:33 +0000)
committernfreear <nfreear>
Tue, 25 Sep 2007 11:33:30 +0000 (11:33 +0000)
lib/weblib.php

index 5b0b530cd1cb276c07cbdbf15df5f880981e5e57..f0512e52eca5f1b76ed0bc8372cc3ab444889103 100644 (file)
@@ -1060,6 +1060,8 @@ function print_textfield ($name, $value, $alt = '',$size=50,$maxlength=0, $retur
  * @param boolean $return Indicates whether the function should return the text
  *         as a string or echo it directly to the page being rendered
  * @param string $targetwindow The name of the target page to open the linked page in.
+ * @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
+ * @param array $optionsextra TODO, an array?
  * @return string If $return is true then the entire form is returned as a string.
  * @todo Finish documenting this function<br>
  */
@@ -3193,7 +3195,7 @@ function link_arrow_right($text, $url='', $accesshide=false, $addclass='') {
     if ($text) {
         $htmltext = $text.'&nbsp;';
         if ($accesshide) {
-            $htmltext = '<span class="accesshide">'.$htmltext.'</span>';
+            $htmltext = get_accesshide($htmltext);
         }
     }
     if ($url) {
@@ -3227,7 +3229,7 @@ function link_arrow_left($text, $url='', $accesshide=false, $addclass='') {
     if ($text) {
         $htmltext = '&nbsp;'.$text;
         if ($accesshide) {
-            $htmltext = '<span class="accesshide">'.$htmltext.'</span>';
+            $htmltext = get_accesshide($htmltext);
         }
     }
     if ($url) {
@@ -3240,6 +3242,19 @@ function link_arrow_left($text, $url='', $accesshide=false, $addclass='') {
     return $arrow.$htmltext;
 }
 
+/**
+ * Return a HTML element with the class "accesshide", for accessibility.
+ *   Please use cautiously - where possible, text should be visible!
+ * @param string $text Plain text.
+ * @param string $elem Lowercase element name, default "span".
+ * @param string $class Additional classes for the element.
+ * @param string $attrs Additional attributes string in the form, "name='value' name2='value2'"
+ * @return string HTML string.
+ */
+function get_accesshide($text, $elem='span', $class='', $attrs='') {
+    return "<$elem class=\"accesshide $class\" $attrs>$text</$elem>";
+}
+
 /**
  * Return the breadcrumb trail navigation separator.
  * @return string HTML string.
@@ -3303,8 +3318,7 @@ function print_navigation ($navigation, $separator=0, $return=false) {
         }
 
         //Accessibility: breadcrumb links now in a list, &raquo; replaced with a 'silent' character.
-        $nav_text = get_string('youarehere','access');
-        $output .= '<h2 class="accesshide">'.$nav_text."</h2><ul>\n";
+        $output .= get_accesshide(get_string('youarehere','access'), 'h2')."<ul>\n";
 
         $output .= '<li class="first">'."\n".'<a '.$CFG->frametarget.' onclick="this.target=\''.$CFG->framename.'\'" href="'
                .$CFG->wwwroot.((!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))
@@ -5840,7 +5854,7 @@ function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $fo
     else {
         $skip_text = get_string('skipa', 'access', strip_tags($title));
     }
-    $skip_link = '<a href="#sb-'.$block_id.'" class="skip-block" title="'.$skip_text.'">'."\n".'<span class="accesshide">'.$skip_text.'</span>'."\n".'</a>';
+    $skip_link = '<a href="#sb-'.$block_id.'" class="skip-block" title="'.$skip_text.'">'."\n".get_accesshide($skip_text)."\n".'</a>';
     $skip_dest = '<span id="sb-'.$block_id.'" class="skip-block-to"></span>';
 
     if (! empty($heading)) {
@@ -6506,4 +6520,4 @@ function fix_align_rtl($align) {
 
 
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file