Skip to content

Commit

Permalink
MDL-36874 mod_book: Add uarrow() output renderer.
Browse files Browse the repository at this point in the history
In preparation for Book navigation improvements in MDL-36874, this commit
adds a uarrow() output renderer, to complement rarrow() and larrow().
  • Loading branch information
David Balch committed Oct 28, 2014
1 parent d63a81c commit 7b2eff2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/outputlib.php
Expand Up @@ -278,6 +278,15 @@ class theme_config {
*/
public $larrow = null;

/**
* @var string Accessibility: Up arrow-like character is used in
* the book heirarchical navigation.
* If the theme does not set characters, appropriate defaults
* are set automatically. Please DO NOT
* use ^ - this is confusing for blind users.
*/
public $uarrow = null;

/**
* @var bool Some themes may want to disable ajax course editing.
*/
Expand Down Expand Up @@ -452,11 +461,13 @@ private function __construct($config) {
$baseconfig = $config;
}

$configurable = array('parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'javascripts', 'javascripts_footer',
'parents_exclude_javascripts', 'layouts', 'enable_dock', 'enablecourseajax', 'supportscssoptimisation',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'hidefromselector', 'doctype',
'yuicssmodules', 'blockrtlmanipulations', 'lessfile', 'extralesscallback', 'lessvariablescallback',
'blockrendermethod');
$configurable = array(
'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets',
'javascripts', 'javascripts_footer', 'parents_exclude_javascripts',
'layouts', 'enable_dock', 'enablecourseajax', 'supportscssoptimisation',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'uarrow',
'hidefromselector', 'doctype', 'yuicssmodules', 'blockrtlmanipulations',
'lessfile', 'extralesscallback', 'lessvariablescallback', 'blockrendermethod');

foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {
Expand Down Expand Up @@ -533,7 +544,7 @@ public function init_page(moodle_page $page) {
}

/**
* Checks if arrows $THEME->rarrow, $THEME->larrow have been set (theme/-/config.php).
* Checks if arrows $THEME->rarrow, $THEME->larrow, $THEME->uarrow have been set (theme/-/config.php).
* If not it applies sensible defaults.
*
* Accessibility: right and left arrow Unicode characters for breadcrumb, calendar,
Expand All @@ -546,6 +557,7 @@ private function check_theme_arrows() {
// Also OK in Win 9x/2K/IE 5.x
$this->rarrow = '►';
$this->larrow = '◄';
$this->uarrow = '▲';
if (empty($_SERVER['HTTP_USER_AGENT'])) {
$uagent = '';
} else {
Expand All @@ -564,13 +576,15 @@ private function check_theme_arrows() {
// So we use the same ones Konqueror uses.
$this->rarrow = '→';
$this->larrow = '←';
$this->uarrow = '↑';
}
elseif (isset($_SERVER['HTTP_ACCEPT_CHARSET'])
&& false === stripos($_SERVER['HTTP_ACCEPT_CHARSET'], 'utf-8')) {
// (Win/IE 5 doesn't set ACCEPT_CHARSET, but handles Unicode.)
// To be safe, non-Unicode browsers!
$this->rarrow = '>';
$this->larrow = '<';
$this->uarrow = '^';
}

// RTL support - in RTL languages, swap r and l arrows
Expand Down
13 changes: 13 additions & 0 deletions lib/outputrenderers.php
Expand Up @@ -3189,6 +3189,19 @@ public function larrow() {
return $this->page->theme->larrow;
}

/**
* Accessibility: Up arrow-like character is used in
* the book heirarchical navigation.
* If the theme does not set characters, appropriate defaults
* are set automatically. Please DO NOT
* use ^ - this is confusing for blind users.
*
* @return string
*/
public function uarrow() {
return $this->page->theme->uarrow;
}

/**
* Returns the custom menu if one has been set
*
Expand Down

0 comments on commit 7b2eff2

Please sign in to comment.