New class that models the behavior of a chat activity!
Isn't it so small and cute? ;-)
This commit is contained in:
+71
-1
@@ -71,6 +71,7 @@ function page_map_class($type, $classname = NULL) {
|
||||
$mappings = array(
|
||||
PAGE_COURSE_VIEW => 'page_course',
|
||||
PAGE_QUIZ_VIEW => 'page_quiz',
|
||||
PAGE_CHAT_VIEW => 'page_chat',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -560,7 +561,7 @@ class page_generic_activity extends page_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Class that models the behavior of a moodle quiz
|
||||
* Class that models the behavior of a quiz
|
||||
*
|
||||
* @author Jon Papaioannou
|
||||
* @package pages
|
||||
@@ -632,4 +633,73 @@ class page_quiz extends page_generic_activity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class that models the behavior of a chat
|
||||
*
|
||||
* @author Jon Papaioannou
|
||||
* @package pages
|
||||
*/
|
||||
|
||||
class page_chat extends page_generic_activity {
|
||||
|
||||
function init_quick($data) {
|
||||
if(empty($data->pageid)) {
|
||||
error('Cannot quickly initialize page: empty course id');
|
||||
}
|
||||
$this->activityname = 'chat';
|
||||
parent::init_quick($data);
|
||||
}
|
||||
|
||||
function print_header($title, $morebreadcrumbs = NULL) {
|
||||
global $USER, $CFG;
|
||||
|
||||
$this->init_full();
|
||||
$replacements = array(
|
||||
'%fullname%' => $this->activityrecord->name
|
||||
);
|
||||
foreach($replacements as $search => $replace) {
|
||||
$title = str_replace($search, $replace, $title);
|
||||
}
|
||||
|
||||
$breadcrumbs = array(
|
||||
$this->courserecord->shortname => $CFG->wwwroot.'/course/view.php?id='.$this->courserecord->id,
|
||||
get_string('modulenameplural', 'chat') => $CFG->wwwroot.'/mod/chat/index.php?id='.$this->courserecord->id,
|
||||
$this->activityrecord->name => $CFG->wwwroot.'/mod/chat/view.php?id='.$this->modulerecord->id,
|
||||
);
|
||||
|
||||
if(!empty($morebreadcrumbs)) {
|
||||
$breadcrumbs = array_merge($breadcrumbs, $morebreadcrumbs);
|
||||
}
|
||||
|
||||
$total = count($breadcrumbs);
|
||||
$current = 1;
|
||||
$crumbtext = '';
|
||||
foreach($breadcrumbs as $text => $href) {
|
||||
if($current++ == $total) {
|
||||
$crumbtext .= ' '.$text;
|
||||
}
|
||||
else {
|
||||
$crumbtext .= ' <a href="'.$href.'">'.$text.'</a> ->';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($morebreadcrumbs) && $this->user_allowed_editing()) {
|
||||
$buttons = '<table><tr><td>'.update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'chat')).'</td>'.
|
||||
'<td><form target="'.$CFG->framename.'" method="get" action="view.php">'.
|
||||
'<input type="hidden" name="id" value="'.$this->modulerecord->id.'" />'.
|
||||
'<input type="hidden" name="edit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'turneditingoff':'blocksaddedit').'" /></form></td></tr></table>';
|
||||
}
|
||||
else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord));
|
||||
|
||||
}
|
||||
|
||||
function get_type() {
|
||||
return PAGE_CHAT_VIEW;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user