From 473327030e370569116a2018f4b05ce10cdd6dac Mon Sep 17 00:00:00 2001 From: Jason Fowler Date: Fri, 8 Mar 2013 14:28:28 +0800 Subject: [PATCH] MDL-32946 - Blocks - Improving image alts for accessibility. --- blocks/dock.js | 6 ++++-- blocks/moodleblock.class.php | 8 ++++++++ lang/en/block.php | 1 + lib/blocklib.php | 16 ++++++++++------ lib/outputrequirementslib.php | 7 +++++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/blocks/dock.js b/blocks/dock.js index d555668bec8..1ebe618c005 100644 --- a/blocks/dock.js +++ b/blocks/dock.js @@ -836,7 +836,8 @@ M.core_dock.genericblock.prototype = { } // Must set the image src seperatly of we get an error with XML strict headers - var moveto = Y.Node.create(''); + var moveto = Y.Node.create(''); var icon = 't/block_to_dock'; if (right_to_left()) { icon = 't/block_to_dock_rtl'; @@ -906,7 +907,8 @@ M.core_dock.genericblock.prototype = { } // Must set the image src seperatly of we get an error with XML strict headers - var movetoimg = Y.Node.create(''+M.str.block.undockitem+''); + var movetoimg = Y.Node.create(''+Y.Escape.html(M.str.block.undockitem)+''); var icon = 't/dock_to_block'; if (right_to_left()) { icon = 't/dock_to_block_rtl'; diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 236c103c61e..4a5475418ee 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -59,6 +59,12 @@ class block_base { */ var $title = NULL; + /** + * The name of the block to be displayed in the block title area if the title is empty. + * @var string arialabel + */ + var $arialabel = NULL; + /** * The type of content that this block creates. Currently support options - BLOCK_TYPE_LIST, BLOCK_TYPE_TEXT * @var int $content_type @@ -240,8 +246,10 @@ class block_base { if (!$this->hide_header()) { $bc->title = $this->title; } + if (empty($bc->title)) { $bc->arialabel = new lang_string('pluginname', get_class($this)); + $this->arialabel = $bc->arialabel; } if ($this->page->user_is_editing()) { diff --git a/lang/en/block.php b/lang/en/block.php index 066fb302a31..00527cd0ff2 100644 --- a/lang/en/block.php +++ b/lang/en/block.php @@ -43,6 +43,7 @@ $string['deletecheck'] = 'Delete {$a} block?'; $string['deleteblock'] = 'Delete {$a} block'; $string['deleteblockcheck'] = 'Are you sure that you want to delete this block titled {$a}?'; $string['deleteblockwarning'] = '

You are about to delete a block that appears elsewhere.

Original block location: {$a->location}
Display on page types: {$a->pagetype}

Are you sure you want to continue?

'; +$string['dockblock'] = 'Dock {$a} block'; $string['hideblock'] = 'Hide {$a} block'; $string['hidedockpanel'] = 'Hide the dock panel'; $string['hidepanel'] = 'Hide panel'; diff --git a/lib/blocklib.php b/lib/blocklib.php index 4d871155235..f7ab795fae7 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1025,25 +1025,29 @@ class block_manager { $controls = array(); $actionurl = $this->page->url->out(false, array('sesskey'=> sesskey())); + $blocktitle = $block->title; + if (empty($blocktitle)) { + $blocktitle = $block->arialabel; + } if ($this->page->user_can_edit_blocks()) { // Move icon. $controls[] = array('url' => $actionurl . '&bui_moveid=' . $block->instance->id, - 'icon' => 't/move', 'caption' => get_string('moveblock', 'block', $block->title), + 'icon' => 't/move', 'caption' => get_string('moveblock', 'block', $blocktitle), 'class' => 'editing_move'); } if ($this->page->user_can_edit_blocks() || $block->user_can_edit()) { // Edit config icon - always show - needed for positioning UI. $controls[] = array('url' => $actionurl . '&bui_editid=' . $block->instance->id, - 'icon' => 't/edit', 'caption' => get_string('configureblock', 'block', $block->title), + 'icon' => 't/edit', 'caption' => get_string('configureblock', 'block', $blocktitle), 'class' => 'editing_edit'); } if ($this->user_can_delete_block($block)) { // Delete icon. $controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id, - 'icon' => 't/delete', 'caption' => get_string('deleteblock', 'block', $block->title), + 'icon' => 't/delete', 'caption' => get_string('deleteblock', 'block', $blocktitle), 'class' => 'editing_delete'); } @@ -1051,11 +1055,11 @@ class block_manager { // Show/hide icon. if ($block->instance->visible) { $controls[] = array('url' => $actionurl . '&bui_hideid=' . $block->instance->id, - 'icon' => 't/hide', 'caption' => get_string('hideblock', 'block', $block->title), + 'icon' => 't/hide', 'caption' => get_string('hideblock', 'block', $blocktitle), 'class' => 'editing_hide'); } else { $controls[] = array('url' => $actionurl . '&bui_showid=' . $block->instance->id, - 'icon' => 't/show', 'caption' => get_string('showblock', 'block', $block->title), + 'icon' => 't/show', 'caption' => get_string('showblock', 'block', $blocktitle), 'class' => 'editing_show'); } } @@ -1070,7 +1074,7 @@ class block_manager { $controls[] = array('url' => $CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php?contextid=' . $block->context->id . '&returnurl=' . urlencode($return), - 'icon' => 't/assignroles', 'caption' => get_string('assignrolesinblock', 'block', $block->title), + 'icon' => 't/assignroles', 'caption' => get_string('assignrolesinblock', 'block', $blocktitle), 'class' => 'editing_roles'); } diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 24e5d0d313b..e80d28115a4 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -676,8 +676,11 @@ class page_requirements_manager { case 'core_dock': $module = array('name' => 'core_dock', 'fullpath' => '/blocks/dock.js', - 'requires' => array('base', 'node', 'event-custom', 'event-mouseenter', 'event-resize'), - 'strings' => array(array('addtodock', 'block'),array('undockitem', 'block'),array('undockblock', 'block'),array('undockall', 'block'),array('thisdirectionvertical', 'langconfig'),array('hidedockpanel', 'block'),array('hidepanel', 'block'))); + 'requires' => array('base', 'node', 'event-custom', 'event-mouseenter', 'event-resize', 'escape'), + 'strings' => array(array('addtodock', 'block'),array('undockitem', 'block'),array('dockblock', 'block'), + array('undockblock', 'block'),array('undockall', 'block'),array('thisdirectionvertical', 'langconfig'), + array('hidedockpanel', 'block'),array('hidepanel', 'block') + )); break; case 'core_message': $module = array('name' => 'core_message',