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

@ -249,9 +249,9 @@ class page_base {
return $this->id;
}
// "Sensible default" case here. Don't trigger any error.
// "Sensible default" case here. Take it from the body id.
function get_format_name() {
return NULL;
return $this->body_id;
}
// Returns $this->body_class
@ -388,7 +388,10 @@ class page_course extends page_base {
// the format_name might be that activity's name etc.
function get_format_name() {
$this->init_full();
return $this->courserecord->format;
if($this->id == SITEID) {
return parent::get_format_name();
}
return $this->body_id.'-'.$this->courserecord->format;
}
// This should return a fully qualified path to the URL which is responsible for displaying us.
@ -610,13 +613,6 @@ class page_quiz extends page_base {
return PAGE_QUIZ_VIEW;
}
// This is like the "category" of a page of this "type". For example, if the type is PAGE_COURSE_VIEW
// the format_name is the actual name of the course format. If the type were PAGE_ACTIVITY_VIEW, then
// the format_name might be that activity's name etc.
function get_format_name() {
return 'quiz';
}
// This should return a fully qualified path to the URL which is responsible for displaying us.
function url_get_path() {
global $CFG;