';
+ $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".''."\n".''."\n";
+ $backmod = '
';
}
if ($nextmod) {
$nexttext= get_string('activitynext', 'access');
- $nextmod = '
'."\n".''."\n".''."\n";
+ $nextmod = '
';
}
return '