diff --git a/admin/report/simpletest/ex_reporter.php b/admin/report/simpletest/ex_reporter.php index 4b1b2022f87..6bae1fba1c6 100644 --- a/admin/report/simpletest/ex_reporter.php +++ b/admin/report/simpletest/ex_reporter.php @@ -45,8 +45,7 @@ class ExHtmlReporter extends HtmlReporter { $this->strrunonlyfolder = $this->get_string('runonlyfolder'); $this->strrunonlyfile = $this->get_string('runonlyfile'); - check_theme_arrows(); - $this->strseparator = ' '.$THEME->rarrow.' '; + $this->strseparator = get_separator(); } /** diff --git a/blocks/search_forums/block_search_forums.php b/blocks/search_forums/block_search_forums.php index 3630c6dd5ab..3bcb5565851 100644 --- a/blocks/search_forums/block_search_forums.php +++ b/blocks/search_forums/block_search_forums.php @@ -29,8 +29,7 @@ class block_search_forums extends block_base { $search = get_string('search'); //Accessibility: replaced with configurable text/'silent' character. - check_theme_arrows(); - // Theme config, $CFG->block_search_button = $THEME->rarrow .''.get_string('search').''; + // Theme config, $CFG->block_search_button = link_arrow_right(get_string('search'), $url='', $accesshide=true); $button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go'); $this->content->text = '
'; diff --git a/calendar/lib.php b/calendar/lib.php index cbc1326fe8a..bd166dd3540 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -620,31 +620,28 @@ function calendar_top_controls($type, $data) { $data['y'] = $date['year']; //Accessibility: calendar block controls, replaced with
. - check_theme_arrows(); - $nexttext = $THEME->rarrow .''.get_string('monthnext','access').''; - $prevtext = $THEME->larrow .''.get_string('monthprev','access').''; + //$nexttext = link_arrow_right(get_string('monthnext', 'access'), $url='', $accesshide=true); + //$prevtext = link_arrow_left(get_string('monthprev', 'access'), $url='', $accesshide=true); switch($type) { case 'frontpage': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); - $nextlink = calendar_get_link_tag($nexttext, 'index.php?', 0, $nextmonth, $nextyear); - $prevlink = calendar_get_link_tag($prevtext, 'index.php?', 0, $prevmonth, $prevyear); - $content .= '
'; - $content .= ''.$prevlink."\n"; + $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'index.php?', 0, $nextmonth, $nextyear, $accesshide=true); + $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'index.php?', 0, $prevmonth, $prevyear, true); + $content .= "\n".'
'. $prevlink; $content .= ' | '.userdate($time, get_string('strftimemonthyear')).''; - $content .= ' | '.$nextlink."\n"; + $content .= ' | '. $nextlink ."\n"; $content .= "
\n"; break; case 'course': list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']); list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); - $nextlink = calendar_get_link_tag($nexttext, 'view.php?id='.$data['id'].'&', 0, $nextmonth, $nextyear); - $prevlink = calendar_get_link_tag($prevtext, 'view.php?id='.$data['id'].'&', 0, $prevmonth, $prevyear); - $content .= '
'; - $content .= ''.$prevlink."\n"; + $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'view.php?id='.$data['id'].'&', 0, $nextmonth, $nextyear, $accesshide=true); + $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'view.php?id='.$data['id'].'&', 0, $prevmonth, $prevyear, true); + $content .= "\n".'
'. $prevlink; $content .= ' | '.userdate($time, get_string('strftimemonthyear')).''; - $content .= ' | '.$nextlink."\n"; + $content .= ' | '. $nextlink ."\n"; $content .= "
\n"; break; case 'upcoming': @@ -658,10 +655,10 @@ function calendar_top_controls($type, $data) { list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']); $prevdate = make_timestamp($prevyear, $prevmonth, 1); $nextdate = make_timestamp($nextyear, $nextmonth, 1); - $content .= '
'; - $content .= ' $THEME->larrow ".userdate($prevdate, get_string('strftimemonthyear')).''; + $content .= "\n".'
'; + $content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month&', 1, $prevmonth, $prevyear); $content .= ' | '.userdate($time, get_string('strftimemonthyear'))."\n"; - $content .= ' | '.userdate($nextdate, get_string('strftimemonthyear'))." $THEME->rarrow\n"; + $content .= ' | '.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month&', 1, $nextmonth, $nextyear); $content .= "
\n"; break; case 'day': @@ -670,9 +667,9 @@ function calendar_top_controls($type, $data) { $nextdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1)); $prevname = calendar_wday_name($CALENDARDAYS[$prevdate['wday']]); $nextname = calendar_wday_name($CALENDARDAYS[$nextdate['wday']]); - $content .= '
'; - $content .= '$THEME->larrow ".$prevname."\n"; - + $content .= "\n".'
'; + $content .= calendar_get_link_previous($prevname, 'view.php?view=day&', $prevdate['mday'], $prevdate['mon'], $prevdate['year']); + // Get the format string $text = get_string('strftimedaydate'); /* @@ -685,7 +682,7 @@ function calendar_top_controls($type, $data) { // Print the actual thing $content .= ' | '.$text.''; - $content .= ' | '.$nextname." $THEME->rarrow\n"; + $content .= ' | '. calendar_get_link_next($nextname, 'view.php?view=day&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']); $content .= "
\n"; break; } @@ -854,6 +851,34 @@ function calendar_get_link_tag($text, $linkbase, $d, $m, $y) { return ''.$text.''; } +/** + * Build and return a previous month HTML link, with an arrow. + * @param string $text The text label. + * @param string $linkbase The URL stub. + * @param int $d $m $y Day of month, month and year numbers. + * @param bool $accesshide Default visible, or hide from all except screenreaders. + * @return string HTML string. + */ +function calendar_get_link_previous($text, $linkbase, $d, $m, $y, $accesshide=false) { + $href = calendar_get_link_href($linkbase, $d, $m, $y); + if(empty($href)) return $text; + return link_arrow_left($text, $href, $accesshide, 'previous'); +} + +/** + * Build and return a next month HTML link, with an arrow. + * @param string $text The text label. + * @param string $linkbase The URL stub. + * @param int $d $m $y Day of month, month and year numbers. + * @param bool $accesshide Default visible, or hide from all except screenreaders. + * @return string HTML string. + */ +function calendar_get_link_next($text, $linkbase, $d, $m, $y, $accesshide=false) { + $href = calendar_get_link_href($linkbase, $d, $m, $y); + if(empty($href)) return $text; + return link_arrow_right($text, $href, $accesshide, 'next'); +} + function calendar_wday_name($englishname) { return get_string(strtolower($englishname), 'calendar'); } diff --git a/lib/weblib.php b/lib/weblib.php index 66e38ac096f..b0d063eb643 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2202,10 +2202,11 @@ function print_header ($title='', $heading='', $navigation='', $focus='', } @header('Accept-Ranges: none'); + $currentlanguage = current_language(); + if (empty($usexml)) { $direction = ' xmlns="http://www.w3.org/1999/xhtml"'. $direction; // See debug_header } else { - $currentlanguage = current_language(); $mathplayer = preg_match("/MathPlayer/i", $_SERVER['HTTP_USER_AGENT']); if(!$mathplayer) { header('Content-Type: application/xhtml+xml'); @@ -2262,6 +2263,8 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $pageclass .= ' drag'; } + $pageclass .= ' lang-'.$currentlanguage; + $bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"'; ob_start(); @@ -2833,6 +2836,85 @@ function check_theme_arrows() { } } +/** + * Return the right arrow with text ('next'), and optionally embedded in a link. + * See function above, check_theme_arrows. + * To see examples of this function in use, see function get_separator below (simple), + * and function calendar_get_link_next in calendar/lib.php (more complex). + * @param string $text Plain text label (set to blank only for breadcrumb separator cases). + * @param string $url An optional link to use in a surrounding HTML anchor. + * @param bool $accesshide True if text should be hidden (for screen readers only). + * @param string $addclass Additional class names for the link, or the arrow character. + * @return string HTML string. + */ +function link_arrow_right($text, $url='', $accesshide=false, $addclass='') { + global $THEME; + check_theme_arrows(); + $arrowclass = 'arrow '; + if (! $url) { + $arrowclass .= $addclass; + } + $arrow = ''.$THEME->rarrow.''; + $htmltext = ''; + if ($text) { + $htmltext = htmlspecialchars($text).' '; + if ($accesshide) { + $htmltext = ''.$htmltext.''; + } + } + if ($url) { + $class = ''; + if ($addclass) { + $class =" class=\"$addclass\""; + } + return ''.$htmltext.$arrow.''; + } + return $htmltext.$arrow; +} + +/** + * Return the left arrow with text ('previous'), and optionally embedded in a link. + * See function above, check_theme_arrows. + * @param string $text Plain text label (set to blank only for breadcrumb separator cases). + * @param string $url An optional link to use in a surrounding HTML anchor. + * @param bool $accesshide True if text should be hidden (for screen readers only). + * @param string $addclass Additional class names for the link, or the arrow character. + * @return string HTML string. + */ +function link_arrow_left($text, $url='', $accesshide=false, $addclass='') { + global $THEME; + check_theme_arrows(); + $arrowclass = 'arrow '; + if (! $url) { + $arrowclass .= $addclass; + } + $arrow = ''.$THEME->larrow.''; + $htmltext = ''; + if ($text) { + $htmltext = ' '.htmlspecialchars($text); + if ($accesshide) { + $htmltext = ''.$htmltext.''; + } + } + if ($url) { + $class = ''; + if ($addclass) { + $class =" class=\"$addclass\""; + } + return ''.$arrow.$htmltext.''; + } + return $arrow.$htmltext; +} + +/** + * Return the breadcrumb trail navigation separator. + * @return string HTML string. + */ +function get_separator() { + //Accessibility: the 'hidden' slash is preferred for screen readers. + return ' '.link_arrow_right($text='/', $url='', $accesshide=true, 'sep').' '; +} + /** * Prints breadcrumb trail of links, called in theme/-/header.html * @@ -2846,20 +2928,19 @@ function print_navigation ($navigation, $separator=0, $return=false) { global $CFG, $THEME; $output = ''; - check_theme_arrows(); if (0 === $separator) { - $separator = $THEME->rarrow; + $separator = get_separator(); } - if (!empty($separator)) { + else { $separator = ''. $separator .''; } if ($navigation) { - + if (!is_array($navigation)) { $ar = explode('->', $navigation); $navigation = array(); - + foreach ($ar as $a) { if (strpos($a, '') === false) { $navigation[] = array('title' => $a, 'url' => ''); @@ -2875,17 +2956,17 @@ function print_navigation ($navigation, $separator=0, $return=false) { $site = new object(); $site->shortname = get_string('home'); } - + //Accessibility: breadcrumb links now in a list, » replaced with a 'silent' character. $nav_text = get_string('youarehere','access'); $output .= '

'.$nav_text."

\n"; } @@ -3379,11 +3460,11 @@ has_capability('moodle/course:viewhiddenuserfields', $context)) { /** * Print a specified group's avatar. * - * @param group $group A {@link group} object representing a group or array of groups - * @param int $courseid ? - * @param boolean $large ? - * @param boolean $return ? - * @param boolean $link ? + * @param group $group A single {@link group} object OR array of groups. + * @param int $courseid The course ID. + * @param boolean $large Default small picture, or large. + * @param boolean $return If false print picture, otherwise return the output as string + * @param boolean $link Enclose image in a link to view specified course? * @return string * @todo Finish documenting this function */ @@ -4353,7 +4434,6 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { } } //Accessibility: added Alt text, replaced > < with 'silent' character and 'accesshide' text. - check_theme_arrows(); if ($selectmod and has_capability('moodle/site:viewreports', $context)) { $logstext = get_string('alllogs'); @@ -4367,15 +4447,15 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { $backtext= get_string('activityprev', 'access'); $backmod = '
  • '."\n".'
    frametarget.'>'."\n".'
    '."\n". ''."\n". - ''."\n".'
    '."\n".''."\n".'
  • '."\n"; + ''."\n".'
    '."\n".''."\n".''."\n"; } if ($nextmod) { $nexttext= get_string('activitynext', 'access'); $nextmod = '
  • '."\n".'
    frametarget.'>'."\n".'
    '."\n". ''."\n". - ''."\n".'
    '."\n".''."\n".'
  • '."\n"; + ''."\n".'
    '."\n".''."\n".''."\n"; } return '