Dropping the use of MOODLE_PAGE_COURSE <gasp>!

The new constant is PAGE_COURSE_VIEW, and it's more streamlined with the
new CSS-related ids for 1.5. There are great possibilities for the future
here, so we 're getting ready.

On the other hand, this has to be the ugliest hack I 've ever inflicted
on any program (look at pagelib.php). Thankfully it will only stay for just
a little while.
This commit is contained in:
defacer 2005-01-31 02:18:15 +00:00
parent 4d411a997f
commit 7542a4e574
14 changed files with 32 additions and 25 deletions

View File

@ -41,7 +41,7 @@
if ($newid = insert_record('course', $form)) {
// Site created, add blocks for it
$page = page_create_object(MOODLE_PAGE_COURSE, $newid);
$page = page_create_object(PAGE_COURSE_VIEW, $newid);
blocks_repopulate_page($page); // Return value not checked because you can always edit later
$cat->name = get_string('miscellaneous');

View File

@ -616,7 +616,7 @@
// Read all of the block table
$blocks = blocks_get_record();
$page = page_create_object(MOODLE_PAGE_COURSE, $preferences->backup_course);
$page = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
if ($instances = blocks_get_by_page($page)) {
//Blocks open tag

View File

@ -590,12 +590,12 @@
$status = true;
delete_records('block_instance', 'pageid', $restore->course_id, 'pagetype', MOODLE_PAGE_COURSE);
delete_records('block_instance', 'pageid', $restore->course_id, 'pagetype', PAGE_COURSE_VIEW);
if (empty($backup_block_format)) { // This is a backup from Moodle < 1.5
if (empty($blockinfo)) {
echo ' (pre 1.3)'; //debug
// Looks like it's from Moodle < 1.3. Let's give the course default blocks...
$newpage = page_create_object(MOODLE_PAGE_COURSE, $restore->course_id);
$newpage = page_create_object(PAGE_COURSE_VIEW, $restore->course_id);
blocks_repopulate_page($newpage);
} else {
echo ' (1.3-1.4)'; //debug
@ -622,7 +622,7 @@
}
$blockinstance->blockid = $blockrecords[$blockname]->id;
$blockinstance->pageid = $restore->course_id;
$blockinstance->pagetype = MOODLE_PAGE_COURSE;
$blockinstance->pagetype = PAGE_COURSE_VIEW;
$blockinstance->position = $blockposition;
$blockinstance->weight = $blockweight;
if(!$status = insert_record('block_instance', $blockinstance)) {

View File

@ -8,7 +8,7 @@ class block_course_summary extends block_base {
}
function specialization() {
if($this->instance->pagetype == MOODLE_PAGE_COURSE && $this->instance->pageid != SITEID) {
if($this->instance->pagetype == PAGE_COURSE_VIEW && $this->instance->pageid != SITEID) {
$this->title = get_string('coursesummary', 'block_course_summary');
}
}

View File

@ -93,7 +93,7 @@ global $CFG;
$instance = new stdClass;
$instance->blockid = abs($blk);
$instance->pageid = $thiscourse->id;
$instance->pagetype = MOODLE_PAGE_COURSE;
$instance->pagetype = PAGE_COURSE_VIEW;
$instance->position = BLOCK_POS_LEFT;
$instance->weight = $weight;
$instance->visible = ($blk > 0) ? 1 : 0;
@ -107,7 +107,7 @@ global $CFG;
$instance = new stdClass;
$instance->blockid = abs($blk);
$instance->pageid = $thiscourse->id;
$instance->pagetype = MOODLE_PAGE_COURSE;
$instance->pagetype = PAGE_COURSE_VIEW;
$instance->position = BLOCK_POS_RIGHT;
$instance->weight = $weight;
$instance->visible = ($blk > 0) ? 1 : 0;

View File

@ -91,7 +91,7 @@ global $CFG;
$instance = new stdClass;
$instance->blockid = abs($blk);
$instance->pageid = $thiscourse->id;
$instance->pagetype = MOODLE_PAGE_COURSE;
$instance->pagetype = PAGE_COURSE_VIEW;
$instance->position = BLOCK_POS_LEFT;
$instance->weight = $weight;
$instance->visible = ($blk > 0) ? 1 : 0;
@ -105,7 +105,7 @@ global $CFG;
$instance = new stdClass;
$instance->blockid = abs($blk);
$instance->pageid = $thiscourse->id;
$instance->pagetype = MOODLE_PAGE_COURSE;
$instance->pagetype = PAGE_COURSE_VIEW;
$instance->position = BLOCK_POS_RIGHT;
$instance->weight = $weight;
$instance->visible = ($blk > 0) ? 1 : 0;

View File

@ -26,7 +26,7 @@ class block_quiz_results extends block_base {
$this->content->text = '';
$this->content->footer = '';
if($this->instance->pagetype == MOODLE_PAGE_COURSE) {
if($this->instance->pagetype == PAGE_COURSE_VIEW) {
// We need to see if we are monitoring a quiz
$quizid = empty($this->config->quizid) ? 0 : $this->config->quizid;
$courseid = $this->instance->pageid;

View File

@ -1,5 +1,5 @@
<table cellpadding="9" cellspacing="0">
<?php if($this->instance->pagetype == MOODLE_PAGE_COURSE) { ?>
<?php if($this->instance->pagetype == PAGE_COURSE_VIEW) { ?>
<tr valign="top">
<td align="right">
<?php print_string('config_select_quiz', 'block_quiz_results') ?>
@ -21,7 +21,7 @@
?>
</td>
</tr>
<?php } // end if($this->instance->pagetype == MOODLE_PAGE_COURSE) ?>
<?php } // end if($this->instance->pagetype == PAGE_COURSE_VIEW) ?>
<tr valign="top">
<td align="right">
<?php print_string('config_show_best', 'block_quiz_results') ?>

View File

@ -70,7 +70,7 @@ class block_rss_client extends block_base {
$isteacher = false;
$courseid = '';
if ($this->instance->pagetype == MOODLE_PAGE_COURSE) {
if ($this->instance->pagetype == PAGE_COURSE_VIEW) {
$isteacher = isteacher($this->instance->pageid);
$courseid = $this->instance->pageid;
}

View File

@ -70,7 +70,7 @@
if (!empty($course)) {
// Test for and remove blocks which aren't appropriate anymore
$page = page_create_object(MOODLE_PAGE_COURSE, $course->id);
$page = page_create_object(PAGE_COURSE_VIEW, $course->id);
blocks_remove_inappropriate($page);
// Update with the new data
@ -91,7 +91,7 @@
if ($newcourseid = insert_record('course', $form)) { // Set up new course
// Setup the blocks
$page = page_create_object(MOODLE_PAGE_COURSE, $newcourseid);
$page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
blocks_repopulate_page($page); // Return value not checked because you can always edit later
$section = NULL;

View File

@ -37,7 +37,7 @@
$course->format = 'weeks'; // Default format is weeks
}
$PAGE = page_create_object(MOODLE_PAGE_COURSE, $course->id);
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
$pageblocks = blocks_get_by_page($PAGE);
if (!isset($USER->editing)) {

View File

@ -56,7 +56,7 @@
$langmenu = popup_form ($CFG->wwwroot .'/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true);
}
$PAGE = page_create_object(MOODLE_PAGE_COURSE, SITEID);
$PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
$editing = $PAGE->user_is_editing();

View File

@ -854,14 +854,14 @@ function upgrade_blocks_plugins($continueto) {
//Iterate over each course
if ($courses = get_records('course')) {
foreach ($courses as $course) {
$page = page_create_object(MOODLE_PAGE_COURSE, $course->id);
$page = page_create_object(PAGE_COURSE_VIEW, $course->id);
blocks_repopulate_page($page);
}
}
}
if (!empty($CFG->siteblocksadded)) { /// This is a once-off hack to make a proper upgrade
$page = page_create_object(MOODLE_PAGE_COURSE, SITEID);
$page = page_create_object(PAGE_COURSE_VIEW, SITEID);
blocks_repopulate_page($page);
delete_records('config', 'name', 'siteblocksadded');
}

View File

@ -12,12 +12,19 @@
* @package pages
*/
// Start of dirty compatibility hack -- this will be here for a couple of weeks
if(record_exists('block_instance', 'pagetype', 'course')) {
execute_sql('UPDATE '.$GLOBALS['CFG']->prefix.'block_instance SET pagetype = \'course-view\' WHERE pagetype = \'course\'', false);
}
// End of dirty compatibility hack -- remove this before 1.5 goes gold
/// Constants
/**
* Definition of course page type.
*/
define('MOODLE_PAGE_COURSE', 'course');
define('PAGE_COURSE_VIEW', 'course-view');
/**
* Factory function page_create_object(). Called with a pagetype identifier and possibly with
@ -59,7 +66,7 @@ function page_map_class($type, $classname = NULL) {
if ($mappings === NULL) {
$mappings = array(
MOODLE_PAGE_COURSE => 'page_course'
PAGE_COURSE_VIEW => 'page_course'
);
}
@ -385,11 +392,11 @@ class page_course extends page_base {
// This is hardwired here so the factory function page_create_object() can be sure there was no mistake.
// Also, it doubles as a way to let others inquire about our type.
function get_type() {
return MOODLE_PAGE_COURSE;
return PAGE_COURSE_VIEW;
}
// This is like the "category" of a page of this "type". For example, if the type is MOODLE_PAGE_COURSE
// the format_name is the actual name of the course format. If the type were MOODLE_PAGE_ACTIVITY, then
// 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() {
$this->init_full();