Permalink
Browse files

MDL-30340 Always generate pagetype patterns in the block settings form

This is an alternative solution to MDL-27812. If the current block
instance has page type set to site-index, we need to provide a way how
that page type pattern can be reset back to other value.
  • Loading branch information...
mudrd8mz authored and stronk7 committed Dec 3, 2011
1 parent 0f9d468 commit b62b7ed0b6efdb51e6fa5cdd10b91c32ec9d1e64
Showing with 12 additions and 16 deletions.
  1. +12 −16 blocks/edit_form.php
View
@@ -126,23 +126,19 @@ function definition() {
$mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
}
+ // Generate pagetype patterns by callbacks
$displaypagetypewarning = false;
- if ($this->page->pagetype == 'site-index') { // No need for pagetype list on home page
- $pagetypelist = array('*'=>get_string('page-x', 'pagetype'));
- } else {
- // Generate pagetype patterns by callbacks
- $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context);
- if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) {
- // Pushing block's existing page type pattern
- $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern);
- if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) {
- $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype');
- } else {
- //as a last resort we could put the page type pattern in the select box
- //however this causes mod-data-view to be added if the only option available is mod-data-*
- // so we are just showing a warning to users about their prev setting being reset
- $displaypagetypewarning = true;
- }
+ $pagetypelist = generate_page_type_patterns($this->page->pagetype, $parentcontext, $this->page->context);
+ if (!array_key_exists($this->block->instance->pagetypepattern, $pagetypelist)) {
+ // Pushing block's existing page type pattern
+ $pagetypestringname = 'page-'.str_replace('*', 'x', $this->block->instance->pagetypepattern);
+ if (get_string_manager()->string_exists($pagetypestringname, 'pagetype')) {
+ $pagetypelist[$this->block->instance->pagetypepattern] = get_string($pagetypestringname, 'pagetype');
+ } else {
+ //as a last resort we could put the page type pattern in the select box
+ //however this causes mod-data-view to be added if the only option available is mod-data-*
+ // so we are just showing a warning to users about their prev setting being reset
+ $displaypagetypewarning = true;
}
}

0 comments on commit b62b7ed

Please sign in to comment.