moodle/blog/blogpage.php

78 lines
2.8 KiB
PHP
Raw Normal View History

2006-03-10 06:53:01 +00:00
<?php // $Id$
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
2006-03-10 06:53:01 +00:00
/**
* Definition of blog page type.
*/
define('PAGE_BLOG_VIEW', 'blog-view');
// Blog class derived from moodle's page class
class page_blog extends page_base {
var $editing = false;
var $filtertype = NULL;
var $filterselect = NULL;
var $tagid = NULL;
2006-03-10 06:53:01 +00:00
// Do any validation of the officially recognized bits of the data and forward to parent.
// Do NOT load up "expensive" resouces (e.g. SQL data) here!
function init_quick($data) {
parent::init_quick($data);
if (empty($data->pageid)) {
//if no pageid then the user is viewing a collection of blog entries
$this->id = 0; //set blog id to 0
}
}
2008-06-01 13:48:12 +00:00
/**
* 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.
*/
2006-03-10 06:53:01 +00:00
function init_full() {
2008-06-01 13:48:12 +00:00
global $DB;
2006-03-10 06:53:01 +00:00
if ($this->full_init_done) {
return;
}
// I need to determine how best to utilize this function. Most init
// is already done before we get here in blogFilter and blogInfo
2006-04-12 08:58:49 +00:00
2006-03-10 06:53:01 +00:00
if ($this->courseid == 0 || $this->courseid == 1 || !is_numeric($this->courseid) ) {
$this->courseid = '';
}
$this->full_init_done = true;
}
2006-03-10 06:53:01 +00:00
//over-ride parent method's print_header because blog already passes more than just the title along
function print_header($pageTitle='', $pageHeading='', $pageNavigation='', $pageFocus='', $pageMeta='') {
global $CFG, $USER;
2006-03-10 06:53:01 +00:00
$this->init_full();
$extraheader = '';
if (!empty($USER) && !empty($USER->id) && $this->user_allowed_editing()) {
if ($this->user_is_editing()) {
$editingString = get_string('turneditingoff');
} else {
$editingString = get_string('turneditingon');
}
$params = $this->url->params();
$params['edit'] = $this->user_is_editing() ? 0 : 1;
$paramstring = '';
foreach ($params as $key=>$val) {
$paramstring .= '<input type="hidden" name="'.$key.'" value="'.s($val).'" />';
}
2007-01-03 19:24:48 +00:00
$extraheader = '<form '.$CFG->frametarget.' method="get" action="'.$this->url->out(false).'"><div>'
.$paramstring.'<input type="submit" value="'.$editingString.'" /></div></form>';
2006-03-10 06:53:01 +00:00
}
print_header($pageTitle, $pageHeading, $pageNavigation, $pageFocus, $pageMeta, true, $extraheader );
}
2006-03-10 06:53:01 +00:00
}
2006-03-16 06:16:54 +00:00
?>