diff --git a/lang/en/block.php b/lang/en/block.php index eefb901376b..066fb302a31 100644 --- a/lang/en/block.php +++ b/lang/en/block.php @@ -47,7 +47,8 @@ $string['hideblock'] = 'Hide {$a} block'; $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'; diff --git a/lib/blocklib.php b/lib/blocklib.php index f96ae319203..43bd6640e53 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -945,8 +945,6 @@ class block_manager { if ($first) { $lastweight = $first->instance->weight - 2; } - - $strmoveblockhere = get_string('moveblockhere', 'block'); } foreach ($instances as $instance) { @@ -957,7 +955,7 @@ class block_manager { 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) { @@ -972,7 +970,7 @@ class block_manager { } 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; } diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 4c42dd152f8..7ad3df779e0 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -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; } } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index ba3c8358a57..68019df055a 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1218,13 +1218,20 @@ class core_renderer extends renderer_base { */ 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.'); } @@ -1236,10 +1243,17 @@ class core_renderer extends renderer_base { * 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')); } /** diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 2afe4866511..8bcf8d31d6b 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -42,6 +42,7 @@ information provided here is intended especially for developers. category_delete_move(), category_delete_full(), move_category(), course_category_hide(), course_category_show(), get_course_category(), create_course_category(), get_all_subcategories(), get_child_categories(), get_categories() +* output renderer changed to support more verbose move-block-here descriptions. Database (DML) layer: * $DB->sql_empty() is deprecated, you have to use sql parameters with empty values instead, diff --git a/theme/mymobile/renderers.php b/theme/mymobile/renderers.php index 6f95a08fde3..e8e64cba3e7 100644 --- a/theme/mymobile/renderers.php +++ b/theme/mymobile/renderers.php @@ -697,16 +697,23 @@ class theme_mymobile_core_renderer extends core_renderer { */ 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.'); } diff --git a/theme/upgrade.txt b/theme/upgrade.txt index ab03c25c0c8..56688c5998c 100644 --- a/theme/upgrade.txt +++ b/theme/upgrade.txt @@ -9,6 +9,9 @@ DOM changes: allows themes to use different CSS reset normalisers such as cssnormalize YUI module * Re-wrote the user profile views to definition lists. +Renderer changes: +* Mymobile theme changed to support more verbose move-block-here descriptions. + === 2.4 === required changes: