MDL-20790 more page layouts -see base theme for full list; also added new css body class for describing current layout; base layout is now default for beter BC; require_login() now sets 'incourse' layout automatically

This commit is contained in:
Petr Skoda
2009-12-27 12:02:04 +00:00
parent 7dccaef182
commit 191b267bcd
40 changed files with 128 additions and 49 deletions
+1
View File
@@ -12,6 +12,7 @@ require_login(0, false);
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_url($CFG->admin . '/settings.php', array('section' => $section));
$PAGE->set_pagetype('admin-setting-' . $section);
$PAGE->set_pagelayout('admin');
$PAGE->navigation->clear_cache();
$adminroot = admin_get_root(); // need all settings
-1
View File
@@ -13,7 +13,6 @@ require_login(0, false);
$adminroot = admin_get_root(); // need all settings
admin_externalpage_setup('upgradesettings'); // now hidden page
$PAGE->set_pagelayout('maintenance');
// now we'll deal with the case that the admin has submitted the form with new settings
if ($data = data_submitted() and confirm_sesskey()) {
+1 -1
View File
@@ -175,7 +175,7 @@ if ($returnurl) {
$managefeeds = new moodle_url($CFG->wwwroot . '/blocks/rss_client/managefeeds.php', $urlparams);
$PAGE->set_url('blocks/rss_client/editfeed.php', $urlparams);
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
if ($rssid) {
$isadding = false;
+1 -1
View File
@@ -78,7 +78,7 @@ $feeds = $DB->get_records_select('block_rss_client', $select, null, $DB->sql_ord
$strmanage = get_string('managefeeds', 'block_rss_client');
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
$PAGE->set_title($strmanage);
$PAGE->set_heading($strmanage);
+1
View File
@@ -167,6 +167,7 @@
$PAGE->set_title("$site->shortname: $category->name");
$PAGE->set_heading("$site->fullname: $strcourses");
$PAGE->set_button(print_course_search('', true, 'navbar'));
$PAGE->set_pagelayout('coursecategory');
echo $OUTPUT->header();
}
+1 -1
View File
@@ -9,7 +9,7 @@
$id = optional_param('id', 0, PARAM_INT); // course id
$categoryid = optional_param('category', 0, PARAM_INT); // course category - can be changed in edit form
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
/// basic access control checks
if ($id) { // editing course
+1 -1
View File
@@ -35,7 +35,7 @@
$return = optional_param('return', 0, PARAM_BOOL); //return to course/view.php if false or mod/modname/view.php if true
$type = optional_param('type', '', PARAM_ALPHANUM); //TODO: hopefully will be removed in 2.0
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
$url = new moodle_url($CFG->wwwroot.'/course/modedit.php');
if (!empty($add)) {
+1 -1
View File
@@ -84,7 +84,7 @@
$PAGE->set_other_editing_capability('moodle/course:manageactivities');
$PAGE->set_url('');
$PAGE->set_docs_path('');
$PAGE->set_pagelayout('home');
$PAGE->set_pagelayout('frontpage');
$editing = $PAGE->user_is_editing();
$PAGE->set_title($SITE->fullname);
$PAGE->set_heading($SITE->fullname);
+1 -1
View File
@@ -1056,7 +1056,7 @@ class block_manager {
}
$editpage = new moodle_page();
$editpage->set_pagelayout('form');
$editpage->set_pagelayout('base');
$editpage->set_course($this->page->course);
$editpage->set_context($block->context);
$editurlbase = str_replace($CFG->wwwroot . '/', '', $this->page->url->out(true));
+5
View File
@@ -2049,6 +2049,9 @@ function get_login_url($loginguest=false) {
* If $cm is given and the coursemodule is hidden and the user is not a teacher
* in the course then the user is redirected to the course home page.
*
* When $cm parameter specified, this function sets page layout to 'module'.
* You need to change it manually later if some other layout needed.
*
* @global object
* @global object
* @global object
@@ -2083,6 +2086,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
}
if ($cm) {
$PAGE->set_cm($cm, $course);
$PAGE->set_pagelayout('incourse');
} else {
$PAGE->set_course($course);
}
@@ -2388,6 +2392,7 @@ function require_course_login($courseorid, $autologinguest=true, $cm=null, $setw
}
if ($cm) {
$PAGE->set_cm($cm, $course);
$PAGE->set_pagelayout('incourse');
} else {
$PAGE->set_course($course);
}
+4 -2
View File
@@ -177,7 +177,7 @@ class theme_config {
* <pre>
* $THEME->layouts = array(
* // Most pages - if we encounter an unknown or amissing page type, this one is used.
* 'normal' => array(
* 'standard' => array(
* 'theme' = 'mytheme',
* 'file' => 'normal.php',
* 'regions' => array('side-pre', 'side-post'),
@@ -999,7 +999,8 @@ class theme_config {
if (array_key_exists($pagelayout, $this->layouts)) {
return $this->layouts[$pagelayout];
} else {
return $this->layouts['normal'];
debugging('Invalid page layout specified: ' . $pagelayout);
return $this->layouts['standard'];
}
}
@@ -1028,6 +1029,7 @@ class theme_config {
}
}
debugging('Can not find layout file for: ' . $pagelayout);
// fallback to standard normal layout
return "$CFG->dirroot/theme/base/layout/general.php";
}
+1 -1
View File
@@ -1692,7 +1692,7 @@ class core_renderer extends renderer_base {
@header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
}
$this->page->set_url(''); // no url
//$this->page->set_pagelayout('form'); //TODO: MDL-20676 blocks on error pages are weird, unfortunately it somehow detect the pagelayout from URL :-(
//$this->page->set_pagelayout('base'); //TODO: MDL-20676 blocks on error pages are weird, unfortunately it somehow detect the pagelayout from URL :-(
$this->page->set_title(get_string('error'));
$output .= $this->header();
}
+5 -3
View File
@@ -99,7 +99,7 @@ class moodle_page {
protected $_pagetype = null;
protected $_pagelayout = 'normal';
protected $_pagelayout = 'base';
/**
* List of theme layeout options, these are ignored by core.
@@ -292,7 +292,7 @@ class moodle_page {
/**
* Please do not call this method directly, use the ->pagelayout syntax. {@link __get()}.
* @return string the general type of page this is. For example 'normal', 'popup', 'home'.
* @return string the general type of page this is. For example 'standard', 'popup', 'home'.
* Allows the theme to display things differently, if it wishes to.
*/
protected function magic_get_pagelayout() {
@@ -709,7 +709,7 @@ class moodle_page {
/**
* @param string $pagelayout the page layout this is. For example 'popup', 'home'.
* This properly defaults to 'normal', so you only need to call this function if
* This properly defaults to 'base', so you only need to call this function if
* you want something different. The exact range of supported layouts is specified
* in the standard theme.
*/
@@ -1175,6 +1175,8 @@ class moodle_page {
$this->add_body_class('yui-skin-sam'); // Make YUI happy, if it is used.
$this->add_body_class($this->url_to_class_name($CFG->wwwroot));
$this->add_body_class('pagelayout-' . $this->_pagelayout); // extra class describing current page layout
if (!during_initial_install()) {
$this->add_body_class('course-' . $this->_course->id);
$this->add_body_class('context-' . $this->context->id);
-1
View File
@@ -33,7 +33,6 @@
require '../config.php';
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/lib/session-test.php'));
$PAGE->set_pagelayout('form');
error('session test not reimplemented yet'); //DO NOT localize or use print_error()!
//
+1 -1
View File
@@ -32,7 +32,7 @@ $testcookies = optional_param('testcookies', 0, PARAM_BOOL); // request cookie t
$context = get_context_instance(CONTEXT_SYSTEM);
$PAGE->set_course($SITE);
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('login');
/// Initialize variables
$errormsg = '';
+2
View File
@@ -11,6 +11,8 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "assignment", "view all", "index.php?id=$course->id", "");
$strassignments = get_string("modulenameplural", "assignment");
+1 -1
View File
@@ -43,7 +43,7 @@ if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id, false, $cm);
require_capability('mod/chat:chat',$context);
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
/// Check to see if groups are being used here
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
+1
View File
@@ -12,6 +12,7 @@ if (! $course = $DB->get_record('course', array('id'=>$id))) {
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'chat', 'view all', "index.php?id=$course->id", '');
+1
View File
@@ -12,6 +12,7 @@
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "choice", "view all", "index?id=$course->id", "");
+1
View File
@@ -35,6 +35,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$context = get_context_instance(CONTEXT_COURSE, $course->id);
+1
View File
@@ -21,6 +21,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
$capabilities = feedback_load_course_capabilities($course->id);
require_login($course->id);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'feedback', 'view all', htmlspecialchars('index.php?id='.$course->id), $course->id);
+1
View File
@@ -30,6 +30,7 @@ $id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'folder', 'view all', "index.php?id=$course->id", '');
+1
View File
@@ -44,6 +44,7 @@ if ($id) {
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+1
View File
@@ -17,6 +17,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$context = get_context_instance(CONTEXT_COURSE, $course->id);
add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", "");
+1
View File
@@ -15,6 +15,7 @@
}
require_login($course->id);
$PAGE->set_pagelayout('incourse');
$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
+1
View File
@@ -30,6 +30,7 @@ $id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'imscp', 'view all', "index.php?id=$course->id", '');
+1
View File
@@ -36,6 +36,7 @@ if (!$course = $DB->get_record("course", array("id" => $id))) {
}
require_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "lesson", "view all", "index.php?id=$course->id", "");
+1
View File
@@ -30,6 +30,7 @@ $id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'page', 'view all', "index.php?id=$course->id", '');
+1 -1
View File
@@ -115,7 +115,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) =
question_edit_setup('editq', true);
$PAGE->set_url('mod/quiz/edit.php', $thispageurl->params());
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
$defaultcategoryobj = question_make_default_categories($contexts->all());
$defaultcategoryid = $defaultcategoryobj->id;
+2
View File
@@ -16,6 +16,8 @@
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
require_login($course->id);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "quiz", "view all", "index.php?id=$course->id", "");
// Print the header
+1
View File
@@ -30,6 +30,7 @@ $id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'resource', 'view all', "index.php?id=$course->id", '');
+1
View File
@@ -16,6 +16,7 @@
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
+1
View File
@@ -12,6 +12,7 @@
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "survey", "view all", "index.php?id=$course->id", "");
+1
View File
@@ -30,6 +30,7 @@ $id = required_param('id', PARAM_INT); // course id
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_course_login($course, true);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, 'url', 'view all', "index.php?id=$course->id", '');
+1
View File
@@ -15,6 +15,7 @@
}
require_course_login($course);
$PAGE->set_pagelayout('incourse');
add_to_log($course->id, "wiki", "view all", "index.php?id=$course->id", "");
+1 -1
View File
@@ -22,7 +22,7 @@
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
$PAGE->set_url('my/index.php');
$PAGE->set_pagelayout('my');
$PAGE->set_pagelayout('mydashboard');
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
if (($edit != -1) and $PAGE->user_allowed_editing()) {
+1 -1
View File
@@ -31,7 +31,7 @@ $PAGE->set_url('tag/index.php', array('id' => $tag->id));
$PAGE->set_subpage($tag->id);
$PAGE->set_context($systemcontext);
$PAGE->set_blocks_editing_capability('moodle/tag:editblocks');
$PAGE->set_pagelayout('form');
$PAGE->set_pagelayout('base');
$PAGE->requires->yui2_lib('animation');
$PAGE->requires->yui2_lib('autocomplete');
+41 -16
View File
@@ -47,48 +47,73 @@ $THEME->sheets = array(
$THEME->editor_sheets = array();
$THEME->layouts = array(
// Most pages - if we encounter an unknown or a missing page type, this one is used.
'normal' => array(
// Most backwards compatible layout without the blocks - this is the layout used by default
'base' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array(),
),
// Standard layout with blocks, this is recommended for most pages with general information
'standard' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
// Course page
// Main course page
'course' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
'coursecategory' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
// part of course, typical for modules - default page layout if $cm specified in require_login()
'incourse' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
// The site home page.
'home' => array(
'frontpage' => array(
'theme' => 'base',
'file' => 'home.php',
'file' => 'frontpage.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
// Server administration scripts.
'admin' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre'
'defaultregion' => 'side-pre',
),
// My moodle page
'my' => array(
// My dashboard page
'mydashboard' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
// Settings form pages, like course of module settings.
'form' => array(
// My public page
'mypublic' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
'login' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array(),
),
// Pages that appear in pop-up windows - no navigation, no blocks, no header.
'popup' => array(
'theme' => 'base',
@@ -103,7 +128,7 @@ $THEME->layouts = array(
'regions' => array(),
'options' => array('nofooter'),
),
// Embeded pages, like iframe embeded in moodleform
// Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible
'embedded' => array(
'theme' => 'base',
'file' => 'embedded.php',
+39 -14
View File
@@ -78,48 +78,73 @@ $THEME->sheets = array(
$THEME->editor_sheets = array('styles_tinymce');
$THEME->layouts = array(
// Most pages - if we encounter an unknown or a missing page type, this one is used.
'normal' => array(
// Most backwards compatible layout without the blocks - this is the layout used by default
'base' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array(),
),
// Standard layout with blocks, this is recommended for most pages with general information
'standard' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
// Course page
// Main course page
'course' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
'coursecategory' => array(
'theme' => 'base',
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
// Standard module pages - default page layout if $cm specified in require_login()
'module' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
// The site home page.
'home' => array(
'frontpage' => array(
'theme' => 'standard',
'file' => 'home.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
'defaultregion' => 'side-post',
),
// Server administration scripts.
'admin' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre'
'defaultregion' => 'side-pre',
),
// My moodle page
'my' => array(
// My dashboard page
'mydashboard' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post',
),
// My public page
'mypublic' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-post'
),
// Settings form pages, like course of module settings.
'form' => array(
'login' => array(
'theme' => 'standard',
'file' => 'normal.php',
'regions' => array(),
),
// Pages that appear in pop-up windows - no navigation, no blocks, no header.
'popup' => array(
'theme' => 'standard',
@@ -132,7 +157,7 @@ $THEME->layouts = array(
'file' => 'frametop.php',
'regions' => array(),
),
// Embeded pages, like iframe embeded in moodleform
// Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible
'embedded' => array(
'theme' => 'standard',
'file' => 'embedded.php',