2006-03-10 06:53:01 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
2008-06-27 03:35:22 +00:00
|
|
|
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;
|
2006-10-06 10:11:52 +00:00
|
|
|
var $filtertype = NULL;
|
|
|
|
var $filterselect = NULL;
|
2006-10-31 08:50:55 +00:00
|
|
|
var $tagid = NULL;
|
2006-10-06 10:11:52 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2006-10-06 10:11:52 +00:00
|
|
|
|
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-10-06 10:11:52 +00:00
|
|
|
}
|
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='') {
|
2009-05-06 09:00:15 +00:00
|
|
|
global $CFG, $USER;
|
2006-10-06 10:11:52 +00:00
|
|
|
|
2006-03-10 06:53:01 +00:00
|
|
|
$this->init_full();
|
|
|
|
$extraheader = '';
|
2009-05-06 09:00:15 +00:00
|
|
|
if (!empty($USER) && !empty($USER->id) && $this->user_allowed_editing()) {
|
2009-05-06 08:59:29 +00:00
|
|
|
if ($this->user_is_editing()) {
|
2006-03-16 08:45:39 +00:00
|
|
|
$editingString = get_string('turneditingoff');
|
|
|
|
} else {
|
|
|
|
$editingString = get_string('turneditingon');
|
|
|
|
}
|
2006-10-06 10:11:52 +00:00
|
|
|
|
2009-05-06 08:55:53 +00:00
|
|
|
$params = $this->url->params();
|
2009-05-06 08:59:29 +00:00
|
|
|
$params['edit'] = $this->user_is_editing() ? 0 : 1;
|
2006-10-06 10:11:52 +00:00
|
|
|
$paramstring = '';
|
|
|
|
foreach ($params as $key=>$val) {
|
|
|
|
$paramstring .= '<input type="hidden" name="'.$key.'" value="'.s($val).'" />';
|
|
|
|
}
|
2007-01-03 19:24:48 +00:00
|
|
|
|
2009-05-06 09:00:15 +00:00
|
|
|
$extraheader = '<form '.$CFG->frametarget.' method="get" action="'.$this->url->out(false).'"><div>'
|
2007-03-01 05:03:06 +00:00
|
|
|
.$paramstring.'<input type="submit" value="'.$editingString.'" /></div></form>';
|
2006-03-10 06:53:01 +00:00
|
|
|
}
|
2009-05-06 09:00:15 +00:00
|
|
|
print_header($pageTitle, $pageHeading, $pageNavigation, $pageFocus, $pageMeta, true, $extraheader );
|
2006-10-06 10:11:52 +00:00
|
|
|
}
|
2006-03-10 06:53:01 +00:00
|
|
|
}
|
2006-03-16 06:16:54 +00:00
|
|
|
?>
|