Follow-up fix bug MDL-9753, "THEME->larrow, rarrow don't work in stock IE6".

This commit is contained in:
nfreear 2007-05-14 13:28:21 +00:00
parent a5fcd78018
commit a84dea2c30
4 changed files with 123 additions and 47 deletions

View File

@ -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();
}
/**

View File

@ -620,30 +620,28 @@ function calendar_top_controls($type, $data) {
$data['y'] = $date['year'];
//Accessibility: calendar block controls, replaced <table> with <div>.
$nexttext = get_arrow_right().'<span class="accesshide">'.get_string('monthnext','access').'</span>';
$prevtext = get_arrow_left() .'<span class="accesshide">'.get_string('monthprev','access').'</span>';
//$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 .= '<div class="calendar-controls">';
$content .= '<span class="previous" title="'.get_string('monthprev','access').'">'.$prevlink."</span>\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".'<div class="calendar-controls">'. $prevlink;
$content .= '<span class="hide"> | </span><span class="current"><a href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=month&amp;', 1, $data['m'], $data['y']).'">'.userdate($time, get_string('strftimemonthyear')).'</a></span>';
$content .= '<span class="hide"> | </span><span class="next" title="'.get_string('monthnext','access').'">'.$nextlink."</span>\n";
$content .= '<span class="hide"> | </span>'. $nextlink ."\n";
$content .= "<span class=\"clearer\"><!-- --></span></div>\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'].'&amp;', 0, $nextmonth, $nextyear);
$prevlink = calendar_get_link_tag($prevtext, 'view.php?id='.$data['id'].'&amp;', 0, $prevmonth, $prevyear);
$content .= '<div class="calendar-controls">';
$content .= '<span class="previous" title="'.get_string('monthprev','access').'">'.$prevlink."</span>\n";
$nextlink = calendar_get_link_next(get_string('monthnext', 'access'), 'view.php?id='.$data['id'].'&amp;', 0, $nextmonth, $nextyear, $accesshide=true);
$prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), 'view.php?id='.$data['id'].'&amp;', 0, $prevmonth, $prevyear, true);
$content .= "\n".'<div class="calendar-controls">'. $prevlink;
$content .= '<span class="hide"> | </span><span class="current"><a href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=month&amp;course='.$data['id'].'&amp;', 1, $data['m'], $data['y']).'">'.userdate($time, get_string('strftimemonthyear')).'</a></span>';
$content .= '<span class="hide"> | </span><span class="next" title="'.get_string('monthnext','access').'">'.$nextlink."</span>\n";
$content .= '<span class="hide"> | </span>'. $nextlink ."\n";
$content .= "<span class=\"clearer\"><!-- --></span></div>\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 .= '<div class="calendar-controls">';
$content .= '<span class="previous"><a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $prevmonth, $prevyear)."\"> $THEME->larrow ".userdate($prevdate, get_string('strftimemonthyear')).'</a></span>';
$content .= "\n".'<div class="calendar-controls">';
$content .= calendar_get_link_previous(userdate($prevdate, get_string('strftimemonthyear')), 'view.php?view=month&amp;', 1, $prevmonth, $prevyear);
$content .= '<span class="hide"> | </span><span class="current">'.userdate($time, get_string('strftimemonthyear'))."</span>\n";
$content .= '<span class="hide"> | </span><span class="next"><a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $nextmonth, $nextyear).'">'.userdate($nextdate, get_string('strftimemonthyear')).' '.get_arrow_left()."</a></span>\n";
$content .= '<span class="hide"> | </span>'.calendar_get_link_next(userdate($nextdate, get_string('strftimemonthyear')), 'view.php?view=month&amp;', 1, $nextmonth, $nextyear);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
case 'day':
@ -669,8 +667,8 @@ 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 .= '<div class="calendar-controls">';
$content .= '<span class="previous"><a href="'.calendar_get_link_href('view.php?view=day&amp;', $prevdate['mday'], $prevdate['mon'], $prevdate['year'])."\">$THEME->larrow ".$prevname."</a></span>\n";
$content .= "\n".'<div class="calendar-controls">';
$content .= calendar_get_link_previous($prevname, 'view.php?view=day&amp;', $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 .= '<span class="hide"> | </span><span class="current">'.$text.'</span>';
$content .= '<span class="hide"> | </span><span class="next"><a href="'.calendar_get_link_href('view.php?view=day&amp;', $nextdate['mday'], $nextdate['mon'], $nextdate['year']).'">'.$nextname.' '.get_arrow_right()."</a></span>\n";
$content .= '<span class="hide"> | </span>'. calendar_get_link_next($nextname, 'view.php?view=day&amp;', $nextdate['mday'], $nextdate['mon'], $nextdate['year']);
$content .= "<span class=\"clearer\"><!-- --></span></div>\n";
break;
}
@ -853,6 +851,34 @@ function calendar_get_link_tag($text, $linkbase, $d, $m, $y) {
return '<a href="'.$href.'">'.$text.'</a>';
}
/**
* 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');
}

View File

@ -7054,7 +7054,7 @@ function build_navigation($extrabreadcrumbs) {
}
$navigation .= '<li class="first">';
if ($i > 0) {
$navigation .= ' '.get_arrow_right('sep').' ';
$navigation .= get_separator();
}
if ($breadcrumbs[$i]['link'] && $i+1 < $countcrumb) {
$navigation .= "<a onclick=\"this.target='$CFG->framename'\" href=\"{$breadcrumbs[$i]['link']}\">";

View File

@ -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 = '<span class="arrow '.$addclass.'">'.$THEME->rarrow.'</span>';
if ($return) {
return $output;
} else {
echo $output;
$arrowclass = 'arrow ';
if (! $url) {
$arrowclass .= $addclass;
}
$arrow = '<span class="'.$arrowclass.'">'.$THEME->rarrow.'</span>';
$htmltext = '';
if ($text) {
$htmltext = htmlspecialchars($text).'&nbsp;';
if ($accesshide) {
$htmltext = '<span class="accesshide">'.$htmltext.'</span>';
}
}
if ($url) {
$class = '';
if ($addclass) {
$class =" class=\"$addclass\"";
}
return '<a'.$class.' href="'.$url.'" title="'.htmlspecialchars($text).'">'.$htmltext.$arrow.'</a>';
}
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 = '<span class="arrow '.$addclass.'">'.$THEME->larrow.'</span>';
if ($return) {
return $output;
} else {
echo $output;
$arrowclass = 'arrow ';
if (! $url) {
$arrowclass .= $addclass;
}
$arrow = '<span class="'.$arrowclass.'">'.$THEME->larrow.'</span>';
$htmltext = '';
if ($text) {
$htmltext = '&nbsp;'.htmlspecialchars($text);
if ($accesshide) {
$htmltext = '<span class="accesshide">'.$htmltext.'</span>';
}
}
if ($url) {
$class = '';
if ($addclass) {
$class =" class=\"$addclass\"";
}
return '<a'.$class.' href="'.$url.'" title="'.htmlspecialchars($text).'">'.$arrow.$htmltext.'</a>';
}
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 = '<span class="sep">'. $separator .'</span>';
}
if ($navigation) {
@ -4668,17 +4718,17 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
}
if ($backmod) {
$backtext= get_string('activityprev', 'access');
$backmod = '<li>'."\n".'<form action="'.$CFG->wwwroot.'/mod/'.$backmod->mod.'/view.php" '.$CFG->frametarget.'>'."\n".'<div>'."\n".
'<input type="hidden" name="id" value="'.$backmod->cm.'" />'."\n".
'<button type="submit" title="'.$backtext.'">'.get_arrow_left()."\n".
'<span class="accesshide">'.$backtext.'</span>'."\n".'</button>'."\n".'</div>'."\n".'</form>'."\n".'</li>'."\n";
$backmod = '<li><form action="'.$CFG->wwwroot.'/mod/'.$backmod->mod.'/view.php" '.$CFG->frametarget.'><fieldset class="invisiblefieldset">'.
'<input type="hidden" name="id" value="'.$backmod->cm.'" />'.
'<button type="submit" title="'.$backtext.'">'.link_arrow_left($backtext, $url='', $accesshide=true).
'</button></fieldset></form></li>';
}
if ($nextmod) {
$nexttext= get_string('activitynext', 'access');
$nextmod = '<li>'."\n".'<form action="'.$CFG->wwwroot.'/mod/'.$nextmod->mod.'/view.php" '.$CFG->frametarget.'>'."\n".'<div>'."\n".
'<input type="hidden" name="id" value="'.$nextmod->cm.'" />'."\n".
'<button type="submit" title="'.$nexttext.'">'.get_arrow_right()."\n".
'<span class="accesshide">'.$nexttext.'</span>'."\n".'</button>'."\n".'</div>'."\n".'</form>'."\n".'</li>'."\n";
$nextmod = '<li><form action="'.$CFG->wwwroot.'/mod/'.$nextmod->mod.'/view.php" '.$CFG->frametarget.'><fieldset class="invisiblefieldset">'.
'<input type="hidden" name="id" value="'.$nextmod->cm.'" />'.
'<button type="submit" title="'.$nexttext.'">'.link_arrow_right($nexttext, $url='', $accesshide=true).
'</button></fieldset></form></li>';
}
return '<div class="navigation">'."\n".'<ul>'.$logslink . $backmod .