Skip to content

Commit

Permalink
block/config MDL-21375 Restrict options on the front page, and use be…
Browse files Browse the repository at this point in the history
…tter human-readable names
  • Loading branch information
moodler committed Jan 25, 2010
1 parent 7e0eac7 commit 35e0646
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
20 changes: 16 additions & 4 deletions blocks/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function definition() {

$contextoptions = array();
if ( ($parentcontext->contextlevel == CONTEXT_COURSE && $parentcontext->instanceid == SITEID) ||
($parentcontext->contextlevel == CONTEXT_SYSTEM)) {
($parentcontext->contextlevel == CONTEXT_SYSTEM)) { // Home page
$contextoptions[0] = get_string('showonfrontpageonly', 'block');
$contextoptions[1] = get_string('showonfrontpageandsubs', 'block');
$contextoptions[2] = get_string('showonentiresite', 'block');
Expand All @@ -97,9 +97,21 @@ function definition() {
}
$mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);

$pagetypeoptions = matching_page_type_patterns($this->page->pagetype);
$pagetypeoptions = array_combine($pagetypeoptions, $pagetypeoptions);
$mform->addElement('select', 'bui_pagetypepattern', get_string('pagetypes', 'block'), $pagetypeoptions);
if ($this->page->pagetype == 'site-index') { // No need for pagetype list on home page
$pagetypelist = array('*');
} else {
$pagetypelist = matching_page_type_patterns($this->page->pagetype);
}
$pagetypeoptions = array();
foreach ($pagetypelist as $pagetype) { // Find human-readable names for the pagetypes
$pagetypeoptions[$pagetype] = $pagetype;
$pagetypestringname = 'page-'.str_replace('*', 'x',$pagetype); // Better names MDL-21375
$pagetypestring = get_string($pagetypestringname, 'pagetype');
if (substr($pagetypestring, 0, 1) != '[') {
$pagetypeoptions[$pagetype] .= ' ('.$pagetypestring.')';
}
}
$mform->addElement('select', 'bui_pagetypepattern', get_string('restrictpagetypes', 'block'), $pagetypeoptions);

if ($this->page->subpage) {
$subpageoptions = array(
Expand Down
17 changes: 17 additions & 0 deletions lang/en_utf8/pagetype.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
// Pagetypes, as used in block configuration

$string['page-x'] = 'Any page';
$string['page-blog-index'] = 'Blog listing pages';
$string['page-blog-x'] = 'All blog pages';
$string['page-course-x'] = 'Any course page';
$string['page-course-view-x'] = 'Any type of course main page';
$string['page-course-view-weeks'] = 'Any course main page in weeks format';
$string['page-course-view-topics'] = 'Any course main page in topics format';
$string['page-mod-x'] = 'Any activity module page';
$string['page-mod-x-view'] = 'Any main activity module page';
$string['page-site-x'] = 'Any top-level site page';
$string['page-site-index'] = 'The front page only';
$string['page-tag-x'] = 'All tag pages';
$string['page-user-view'] = 'Only user profile pages';
$string['page-user-x'] = 'All user pages';

0 comments on commit 35e0646

Please sign in to comment.