From a84dea2c30c2922872e1e55727224e883a4ae479 Mon Sep 17 00:00:00 2001 From: nfreear Date: Mon, 14 May 2007 13:28:21 +0000 Subject: [PATCH] Follow-up fix bug MDL-9753, "THEME->larrow, rarrow don't work in stock IE6". --- admin/report/simpletest/ex_reporter.php | 2 +- calendar/lib.php | 64 ++++++++++----- lib/moodlelib.php | 2 +- lib/weblib.php | 102 ++++++++++++++++++------ 4 files changed, 123 insertions(+), 47 deletions(-) diff --git a/admin/report/simpletest/ex_reporter.php b/admin/report/simpletest/ex_reporter.php index b671180ea58..6bae1fba1c6 100644 --- a/admin/report/simpletest/ex_reporter.php +++ b/admin/report/simpletest/ex_reporter.php @@ -45,7 +45,7 @@ class ExHtmlReporter extends HtmlReporter { $this->strrunonlyfolder = $this->get_string('runonlyfolder'); $this->strrunonlyfile = $this->get_string('runonlyfile'); - $this->strseparator = ' '.get_arrow_right().' '; + $this->strseparator = get_separator(); } /** diff --git a/calendar/lib.php b/calendar/lib.php index 0a6ee266a95..bd166dd3540 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -620,30 +620,28 @@ function calendar_top_controls($type, $data) { $data['y'] = $date['year']; //Accessibility: calendar block controls, replaced with
. - $nexttext = get_arrow_right().''.get_string('monthnext','access').''; - $prevtext = get_arrow_left() .''.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': @@ -657,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')).' '.get_arrow_left()."\n"; + $content .= ' | '.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month&', 1, $nextmonth, $nextyear); $content .= "
\n"; break; case 'day': @@ -669,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'); /* @@ -684,7 +682,7 @@ function calendar_top_controls($type, $data) { // Print the actual thing $content .= ' | '.$text.''; - $content .= ' | '.$nextname.' '.get_arrow_right()."\n"; + $content .= ' | '. calendar_get_link_next($nextname, 'view.php?view=day&', $nextdate['mday'], $nextdate['mon'], $nextdate['year']); $content .= "
\n"; break; } @@ -853,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/moodlelib.php b/lib/moodlelib.php index 104d501cb55..c84f819ad6d 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -7054,7 +7054,7 @@ function build_navigation($extrabreadcrumbs) { } $navigation .= '
  • '; if ($i > 0) { - $navigation .= ' '.get_arrow_right('sep').' '; + $navigation .= get_separator(); } if ($breadcrumbs[$i]['link'] && $i+1 < $countcrumb) { $navigation .= "framename'\" href=\"{$breadcrumbs[$i]['link']}\">"; diff --git a/lib/weblib.php b/lib/weblib.php index ae44db43919..d32f3ff992c 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3099,36 +3099,83 @@ function check_theme_arrows() { } /** - * Return (by default) the right arrow defined in check_theme_arrows function above. - * @param addclass Additional class names. - * @param return Default true, false means echo. - * @return Default HTML string, or nothing. + * Return the right arrow with text ('next'), 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 get_arrow_right($addclass='', $return=true) { +function link_arrow_right($text, $url='', $accesshide=false, $addclass='') { global $THEME; check_theme_arrows(); - $output = ''.$THEME->rarrow.''; - if ($return) { - return $output; - } else { - echo $output; + $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 (by default) the left arrow defined in check_theme_arrows function above. + * 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 get_arrow_left($addclass='', $return=true) { +function link_arrow_left($text, $url='', $accesshide=false, $addclass='') { global $THEME; check_theme_arrows(); - $output = ''.$THEME->larrow.''; - if ($return) { - return $output; - } else { - echo $output; + $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 @@ -3144,7 +3191,10 @@ function print_navigation ($navigation, $separator=0, $return=false) { $output = ''; if (0 === $separator) { - $separator = get_arrow_right('sep'); + $separator = get_separator(); + } + else { + $separator = ''. $separator .''; } if ($navigation) { @@ -4668,17 +4718,17 @@ function navmenu($course, $cm=NULL, $targetwindow='self') { } if ($backmod) { $backtext= get_string('activityprev', 'access'); - $backmod = '
  • '."\n".'
    frametarget.'>'."\n".'
    '."\n". - ''."\n". - ''."\n".'
    '."\n".''."\n".'
  • '."\n"; + $backmod = '
  • frametarget.'>
    '. + ''. + '
  • '; } if ($nextmod) { $nexttext= get_string('activitynext', 'access'); - $nextmod = '
  • '."\n".'
    frametarget.'>'."\n".'
    '."\n". - ''."\n". - ''."\n".'
    '."\n".''."\n".'
  • '."\n"; + $nextmod = '
  • frametarget.'>
    '. + ''. + '
  • '; } return '