Skip to content

Commit

Permalink
moodle_page: MDL-12212 improve comments and add some work-in-progress…
Browse files Browse the repository at this point in the history
… warnings
  • Loading branch information
tjhunt committed May 6, 2009
1 parent cb64022 commit b7b2d0f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
3 changes: 2 additions & 1 deletion admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@
echo '</form>';

} else {
// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$pageblocks = blocks_setup($PAGE);

$preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
$preferred_width_right = blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]);

// The search page currently doesn't handle block editing
if ($PAGE->user_allowed_editing()) {
$options = $PAGE->url->params();
if ($PAGE->user_is_editing()) {
Expand Down
3 changes: 3 additions & 0 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
$PAGE->set_url('course/view.php', array('id' => $course->id));
$PAGE->set_pagetype('course-view-' . $course->format);
$PAGE->set_other_editing_capability('moodle/course:manageactivities');

// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);

if ($reset_user_allowed_editing) {
Expand Down
3 changes: 2 additions & 1 deletion lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3946,6 +3946,8 @@ function admin_externalpage_print_header($focus='') {
define('ADMIN_EXT_HEADER_PRINTED', 'true');

if (!empty($SITE->fullname) and !empty($SITE->shortname)) {
// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$pageblocks = blocks_setup($PAGE);

$preferred_width_left = blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]);
Expand All @@ -3958,7 +3960,6 @@ function admin_externalpage_print_header($focus='') {
$current = $adminroot->locate($section, true);
$visiblepathtosection = array_reverse($current->visiblepath);

// The search page currently doesn't handle block editing
if ($PAGE->user_allowed_editing()) {
$options = $PAGE->url->params();
if ($PAGE->user_is_editing()) {
Expand Down
40 changes: 26 additions & 14 deletions lib/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class moodle_page {
/// methods, but instead use the $PAGE->x syntax.

/**
* Please do not call this method directly, use the ->state syntax. @see __get().
* @return integer one of the STATE_... constants. You should not normally need
* to use this in your code. It is indended for internal use by this class
* and its friends like print_header, to check that everything is working as
Expand All @@ -125,18 +126,18 @@ public function get_state() {
}

/**
* @return boolean has the header already been printed? Also accessible as
* $PAGE->headerprinted.
* Please do not call this method directly, use the ->headerprinted syntax. @see __get().
* @return boolean has the header already been printed?
*/
public function get_headerprinted() {
return $this->_state >= self::STATE_IN_BODY;
}

/**
* Please do not call this method directly, use the ->course syntax. @see __get().
* @return object the current course that we are inside - a row from the
* course table. (Also available as $COURSE global.) If we are not inside
* an actual course, this will be the site course. You can also access this
* as $PAGE->course.
* an actual course, this will be the site course.
*/
public function get_course() {
global $SITE;
Expand All @@ -147,6 +148,7 @@ public function get_course() {
}

/**
* Please do not call this method directly, use the ->cm syntax. @see __get().
* @return object the course_module that this page belongs to. Will be null
* if this page is not within a module. This is a full cm object, as loaded
* by get_coursemodule_from_id or get_coursemodule_from_instance,
Expand All @@ -157,10 +159,10 @@ public function get_cm() {
}

/**
* @return object the course_module that this page belongs to. Will be null
* if this page is not within a module. This is a full cm object, as loaded
* by get_coursemodule_from_id or get_coursemodule_from_instance,
* so the extra modname and name fields are present.
* Please do not call this method directly, use the ->activityrecord syntax. @see __get().
* @return object the row from the activities own database table (for example
* the forum or quiz table) that this page belongs to. Will be null
* if this page is not within a module.
*/
public function get_activityrecord() {
if (is_null($this->_module) && !is_null($this->_cm)) {
Expand All @@ -170,10 +172,9 @@ public function get_activityrecord() {
}

/**
* @return object the course_module that this page belongs to. Will be null
* if this page is not within a module. This is a full cm object, as loaded
* by get_coursemodule_from_id or get_coursemodule_from_instance,
* so the extra modname and name fields are present.
* Please do not call this method directly, use the ->activityname syntax. @see __get().
* @return string|null the The type of activity we are in, for example 'forum' or 'quiz'.
* Will be null if this page is not within a module.
*/
public function get_activityname() {
if (is_null($this->_cm)) {
Expand All @@ -183,6 +184,7 @@ public function get_activityname() {
}

/**
* Please do not call this method directly, use the ->category syntax. @see __get().
* @return mixed the category that the page course belongs to. If there isn't one
* (that is, if this is the front page course) returns null.
*/
Expand All @@ -196,6 +198,7 @@ public function get_category() {
}

/**
* Please do not call this method directly, use the ->categories syntax. @see __get().
* @return array an array of all the categories the page course belongs to,
* starting with the immediately containing category, and working out to
* the top-level category. This may be the empty array if we are in the
Expand All @@ -207,6 +210,7 @@ public function get_categories() {
}

/**
* Please do not call this method directly, use the ->context syntax. @see __get().
* @return object the main context to which this page belongs.
*/
public function get_context() {
Expand All @@ -217,6 +221,7 @@ public function get_context() {
}

/**
* Please do not call this method directly, use the ->pagetype syntax. @see __get().
* @return string e.g. 'my-index' or 'mod-quiz-attempt'. Same as the id attribute on <body>.
*/
public function get_pagetype() {
Expand All @@ -227,21 +232,24 @@ public function get_pagetype() {
}

/**
* Please do not call this method directly, use the ->subpage syntax. @see __get().
* @return string|null The subpage identifier, if any.
*/
public function get_subpage() {
return $this->_subpage;
}

/**
* Please do not call this method directly, use the ->bodyclasses syntax. @see __get().
* @return string the class names to put on the body element in the HTML.
*/
public function get_bodyclasses() {
return implode(' ', array_keys($this->_bodyclasses));
}

/**
* @return string the class names to put on the body element in the HTML.
* Please do not call this method directly, use the ->docspath syntax. @see __get().
* @return string the path to the Moodle docs for this page.
*/
public function get_docspath() {
if (is_string($this->_docspath)) {
Expand All @@ -252,6 +260,7 @@ public function get_docspath() {
}

/**
* Please do not call this method directly, use the ->url syntax. @see __get().
* @return moodle_url the clean URL required to load the current page. (You
* should normally use this in preference to $ME or $FULLME.)
*/
Expand All @@ -265,6 +274,7 @@ public function get_url() {
}

/**
* Please do not call this method directly, use the ->blocks syntax. @see __get().
* @return blocks_manager the blocks manager object for this page.
*/
public function get_blocks() {
Expand All @@ -281,7 +291,9 @@ public function get_blocks() {
}

/**
* PHP overloading magic to make the $PAGE->course syntax work.
* PHP overloading magic to make the $PAGE->course syntax work by redirecting
* it to the corresponding $PAGE->get_course() method if there is one, and
* throwing an exception if not.
*/
public function __get($field) {
$getmethod = 'get_' . $field;
Expand Down
3 changes: 3 additions & 0 deletions mod/chat/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@

// Initialize $PAGE, compute blocks
$PAGE->set_url('mod/chat/view.php', array('id' => $cm->id));

// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$pageblocks = blocks_setup($PAGE);
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);

Expand Down
2 changes: 2 additions & 0 deletions mod/data/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
}

/// Print the page header
// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$title = $course->shortname.': ' . format_string($data->name);

$buttons = '<table><tr><td>'.update_module_button($cm->id, $course->id, get_string('modulename', 'data')).'</td>';
Expand Down
2 changes: 2 additions & 0 deletions mod/quiz/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
}
require_js(array('yui_yahoo', 'yui_event'));

// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$title = $course->shortname . ': ' . format_string($quiz->name);

$buttons = '<table><tr><td>'.update_module_button($cm->id, $course->id, get_string('modulename', 'quiz')).'</td>';
Expand Down
2 changes: 2 additions & 0 deletions my/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
$PAGE->set_url('my/index.php');
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');

// Note: MDL-19010 there will be further changes to printing header and blocks.
// The code will be much nicer than this eventually.
$pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);

if (($edit != -1) and $PAGE->user_allowed_editing()) {
Expand Down

0 comments on commit b7b2d0f

Please sign in to comment.