Skip to content

Commit

Permalink
MDL-35876 - Blocks - Adding verbose move here descriptions to blocks …
Browse files Browse the repository at this point in the history
…for accessibility
  • Loading branch information
jsnfwlr committed Mar 26, 2013
1 parent 373a8e0 commit 6671fa7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
3 changes: 2 additions & 1 deletion lang/en/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
$string['hidedockpanel'] = 'Hide the dock panel';
$string['hidepanel'] = 'Hide panel';
$string['moveblock'] = 'Move {$a} block';
$string['moveblockhere'] = 'Move block here';
$string['moveblockafter'] = 'Move block to after {$a} block';
$string['moveblockbefore'] = 'Move block to before {$a} block';
$string['movingthisblockcancel'] = 'Moving this block ({$a})';
$string['onthispage'] = 'On this page';
$string['pagetypes'] = 'Page types';
Expand Down
6 changes: 2 additions & 4 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,6 @@ protected function create_block_contents($instances, $output, $region) {
if ($first) {
$lastweight = $first->instance->weight - 2;
}

$strmoveblockhere = get_string('moveblockhere', 'block');
}

foreach ($instances as $instance) {
Expand All @@ -957,7 +955,7 @@ protected function create_block_contents($instances, $output, $region) {

if ($this->movingblock && $lastweight != $instance->instance->weight &&
$content->blockinstanceid != $this->movingblock && $lastblock != $this->movingblock) {
$results[] = new block_move_target($strmoveblockhere, $this->get_move_target_url($region, ($lastweight + $instance->instance->weight)/2));
$results[] = new block_move_target($this->get_move_target_url($region, ($lastweight + $instance->instance->weight)/2));
}

if ($content->blockinstanceid == $this->movingblock) {
Expand All @@ -972,7 +970,7 @@ protected function create_block_contents($instances, $output, $region) {
}

if ($this->movingblock && $lastblock != $this->movingblock) {
$results[] = new block_move_target($strmoveblockhere, $this->get_move_target_url($region, $lastweight + 1));
$results[] = new block_move_target($this->get_move_target_url($region, $lastweight + 1));
}
return $results;
}
Expand Down
9 changes: 1 addition & 8 deletions lib/outputcomponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -2497,18 +2497,11 @@ class block_move_target {
*/
public $url;

/**
* @var string label
*/
public $text;

/**
* Constructor
* @param string $text
* @param moodle_url $url
*/
public function __construct($text, moodle_url $url) {
$this->text = $text;
public function __construct(moodle_url $url) {
$this->url = $url;
}
}
Expand Down
22 changes: 18 additions & 4 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1215,13 +1215,20 @@ public function list_block_contents($icons, $items) {
*/
public function blocks_for_region($region) {
$blockcontents = $this->page->blocks->get_content_for_region($region, $this);

$blocks = $this->page->blocks->get_blocks_for_region($region);
$lastblock = null;
$zones = array();
foreach ($blocks as $block) {
$zones[] = $block->title;
}
$output = '';

foreach ($blockcontents as $bc) {
if ($bc instanceof block_contents) {
$output .= $this->block($bc, $region);
$lastblock = $bc->title;
} else if ($bc instanceof block_move_target) {
$output .= $this->block_move_target($bc);
$output .= $this->block_move_target($bc, $zones, $lastblock);
} else {
throw new coding_exception('Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
}
Expand All @@ -1233,10 +1240,17 @@ public function blocks_for_region($region) {
* Output a place where the block that is currently being moved can be dropped.
*
* @param block_move_target $target with the necessary details.
* @param array $zones array of areas where the block can be moved to
* @param string $previous the block located before the area currently being rendered.
* @return string the HTML to be output.
*/
public function block_move_target($target) {
return html_writer::tag('a', html_writer::tag('span', $target->text, array('class' => 'accesshide')), array('href' => $target->url, 'class' => 'blockmovetarget'));
public function block_move_target($target, $zones, $previous) {
if ($previous == null) {
$position = get_string('moveblockbefore', 'block', $zones[0]);
} else {
$position = get_string('moveblockafter', 'block', $previous);
}
return html_writer::tag('a', html_writer::tag('span', $position, array('class' => 'accesshide')), array('href' => $target->url, 'class' => 'blockmovetarget'));
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ information provided here is intended especially for developers.
* condition_info:get_condition_user_fields($formatoptions) now accepts the optional
param $formatoptions, that will determine if the field names are processed by
format_string() with the passed options.
* output renderer changed to support more verbose move-block-here descriptions.

YUI changes:
* M.util.help_icon has been deprecated. Code should be updated to use moodle-core-popuphelp
Expand Down
11 changes: 9 additions & 2 deletions theme/mymobile/renderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,23 @@ public function notification($message, $classes = 'notifyproblem') {
*/
public function blocks_for_region($region) {
$blockcontents = $this->page->blocks->get_content_for_region($region, $this);

$blocks = $this->page->blocks->get_blocks_for_region($region);
$lastblock = null;
$zones = array();
foreach ($blocks as $block) {
$zones[] = $block->title;
}

$output = '';
foreach ($blockcontents as $bc) {
if ($bc instanceof block_contents) {
$lastblock = $bc->title;
// We don't want to print navigation and settings blocks here.
if ($bc->attributes['class'] != 'block_settings block' && $bc->attributes['class'] != 'block_navigation block') {
$output .= $this->block($bc, $region);
}
} else if ($bc instanceof block_move_target) {
$output .= $this->block_move_target($bc);
$output .= $this->block_move_target($bc, $zones, $lastblock);
} else {
throw new coding_exception('Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
}
Expand Down
3 changes: 3 additions & 0 deletions theme/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ DOM changes:
* new setting $THEME->yuicssmodules = array('cssreset', 'cssfonts', 'cssgrids', 'cssbase'); which
allows themes to use different CSS reset normalisers such as cssnormalize YUI module

Renderer changes:
* Mymobile theme changed to support more verbose move-block-here descriptions.

=== 2.4 ===

required changes:
Expand Down

0 comments on commit 6671fa7

Please sign in to comment.