Changing the way that applicable formats for each block are defined:

The format for each page is now the same as the id attribute of the
BODY tag, which in turn is a simple function of the script's relative path:

The format for e.g. a quiz view page is "mod-quiz-view". The format for the
site index is "site-index". Exception: the format for courses is not just
"course-view", but "course-view-weeks" etc.

Obviously the applicable_formats() override for each block should now take
this into account. The matching rules now are:

* You can specify the full format, e.g. "mod-quiz-view" => true
  will allow the block to be added in quizzes
* Prefixes match the full page format, e.g. "mod" matches ALL activities
* You can use "*" as a wildcard, e.g. "mod-*-view" matches just the view.php
  page of all activities
* These rules interoperate, thus "mod-*" is the same as "mod"
* "all" remains as a catch-all situation
This commit is contained in:
defacer 2005-02-08 02:59:44 +00:00
parent bb64b51aa3
commit 8a47e075b3
5 changed files with 38 additions and 23 deletions

View file

@ -354,7 +354,7 @@ class block_base {
$formats = $this->applicable_formats();
if (empty($formats) || array_sum($formats) === 0) {
$errors[] = 'no_course_formats';
$errors[] = 'no_formats';
$correct = false;
}
@ -418,8 +418,8 @@ class block_base {
* @todo finish documenting this function
*/
function applicable_formats() {
// Default case: the block can be used in all course types and not in quizzes
return array('all' => true, 'quiz' => false);
// Default case: the block can be used in all course types but not in activities
return array('all' => true, 'mod' => false);
}

View file

@ -23,7 +23,7 @@ class block_section_links extends block_base {
}
function applicable_formats() {
return (array('weeks' => true, 'topics' => true));
return (array('course-view-weeks' => true, 'course-view-topics' => true));
}
function get_content() {

View file

@ -8,7 +8,7 @@ class block_social_activities extends block_base {
}
function applicable_formats() {
return array('social' => true);
return array('course-view-social' => true);
}
function get_content() {