MDL-30340 Always generate pagetype patterns in the block settings form
authorDavid Mudrak <david@moodle.com>
Sat, 3 Dec 2011 13:08:52 +0000 (14:08 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Sat, 3 Dec 2011 15:57:21 +0000 (16:57 +0100)
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.

blocks/edit_form.php

index 80b361e..1e1cf8c 100644 (file)
@@ -126,23 +126,19 @@ class block_edit_form extends moodleform {
             $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
         }
 
             $mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
         }
 
+        // Generate pagetype patterns by callbacks
         $displaypagetypewarning = false;
         $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;
             }
         }
 
             }
         }