From e0134f842cfa7d9b1d360162e67ad74cf76ec9c4 Mon Sep 17 00:00:00 2001 From: dhawes <dhawes> Date: Wed, 10 Nov 2004 16:43:57 +0000 Subject: [PATCH] added comments and some spacing cleanup --- blocks/moodleblock.class.php | 7 +++-- lib/pagelib.php | 59 ++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index 50cc758808..f2411737d5 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -1,7 +1,8 @@ <?php // $Id$ /** - * Parent class for moodle blocks + * This file contains the parent class for moodle blocks, MoodleBlock, + * as well as the MoodleBlock_Nuke subclass. * * @author Jon Papaioannou * @version $Id$ @@ -27,7 +28,7 @@ define('BLOCK_TYPE_TEXT', 2); define('BLOCK_TYPE_NUKE', 3); /** - * Class for describing a moodle block + * Class for describing a moodle block, all Moodle blocks derive from this class * * @author Jon Papaioannou * @package blocks @@ -89,7 +90,7 @@ class MoodleBlock { var $config = NULL; -/// Functions +/// Class Functions /** * The class constructor diff --git a/lib/pagelib.php b/lib/pagelib.php index 1d1464e31e..ed63b5d224 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -1,23 +1,53 @@ <?php //$Id$ +/** + * This file contains the parent class for moodle pages, MoodlePage, + * as well as the MoodlePage_Course subclass. + * A page is defined by its page type (ie. course, blog, activity) and its page id + * (courseid, blogid, activity id, etc). + * + * @author Jon Papaioannou + * @version $Id$ + * @license http://www.gnu.org/copyleft/gpl.html GNU Public License + * @package pages + */ + +/// Constants + +/** + * Definition of course page type. + */ define('MOODLE_PAGE_COURSE', 'course'); /** * Parent class from which all Moodle page classes derive * - * @version $Id$ - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @author Jon Papaioannou * @package pages + * @todo This parent class is very messy still. Please for the moment ignore it [except maybe create_object()] and move on to the derived class MoodlePage_Course to see the comments there. */ -// This is very messy still. Please for the moment ignore it [except maybe create_object()] -// and move on to the derived class MoodlePage_Course to see the comments there. class MoodlePage { + /** + * The string identifier for the type of page being described. + * @var string $type + */ var $type = NULL; + + /** + * The numeric identifier of the page being described. + * @var int $id + */ var $id = NULL; + + /** + * Class bool to determine if the instance's full initialization has been completed. + * @var boolean $full_init_done + */ var $full_init_done = false; +/// Class Functions + function blocks_get_positions() { return array(); } @@ -44,7 +74,7 @@ class MoodlePage { foreach($params as $var => $value) { $path .= $first? '?' : '&'; - $path .= $var.'='.urlencode($value); + $path .= $var .'='. urlencode($value); $first = false; } @@ -84,14 +114,14 @@ class MoodlePage { ); if(!isset($typeids[$type])) { - error('Unrecognized type passed to MoodlePage::create_object: '.$type); + error('Unrecognized type passed to MoodlePage::create_object: '. $type); } $object = &new $typeids[$type]; if($object->get_type() !== $type) { // Somehow somewhere someone made a mistake - error("Page object's type (".$object->get_type().") does not match requested type ($type)"); + error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')'); } $object->init_quick($data); @@ -103,8 +133,6 @@ class MoodlePage { /** * Class that models the behavior of a moodle course * - * @version $Id$ - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @author Jon Papaioannou * @package pages */ @@ -125,7 +153,7 @@ class MoodlePage_Course extends MoodlePage { parent::init_quick($data); } - // Here you should load up all heavy-duty data for your course. Basically everything that + // Here you should load up all heavy-duty data for your page. Basically everything that // does not NEED to be loaded for the class to make basic decisions should NOT be loaded // in init_quick() and instead deferred here. Of course this function had better recognize // $this->full_init_done to prevent wasteful multiple-time data retrieval. @@ -135,7 +163,7 @@ class MoodlePage_Course extends MoodlePage { } $this->courserecord = get_record('course', 'id', $this->id); if(empty($this->courserecord)) { - error('Cannot fully initialize page: invalid course id '.$this->id); + error('Cannot fully initialize page: invalid course id '. $this->id); } $this->full_init_done = true; } @@ -187,10 +215,10 @@ class MoodlePage_Course extends MoodlePage { function url_get_path() { global $CFG; if($this->id == SITEID) { - return $CFG->wwwroot.'/index.php'; + return $CFG->wwwroot .'/index.php'; } else { - return $CFG->wwwroot.'/course/view.php'; + return $CFG->wwwroot .'/course/view.php'; } } @@ -276,12 +304,11 @@ class MoodlePage_Course extends MoodlePage { function blocks_move_position(&$instance, $move) { if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) { return BLOCK_POS_RIGHT; - } - else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) { + } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) { return BLOCK_POS_LEFT; } return $instance->position; } } -?> +?> \ No newline at end of file -- 2.39.5