3 require_once($CFG->libdir
.'/pagelib.php');
4 require_once($CFG->dirroot
.'/course/lib.php'); // needed for some blocks
6 define('PAGE_DATA_VIEW', 'mod-data-view');
8 page_map_class(PAGE_DATA_VIEW
, 'page_data');
10 $DEFINEDPAGES = array(PAGE_DATA_VIEW
);
15 * Class that models the behavior of a data
17 * @author Jon Papaioannou
21 class page_data
extends page_generic_activity
{
23 function init_quick($data) {
24 if(empty($data->pageid
)) {
25 error('Cannot quickly initialize page: empty course id');
27 $this->activityname
= 'data';
28 parent
::init_quick($data);
31 function print_header($title, $morebreadcrumbs = NULL, $meta) {
35 $replacements = array(
36 '%fullname%' => format_string($this->activityrecord
->name
)
38 foreach($replacements as $search => $replace) {
39 $title = str_replace($search, $replace, $title);
42 if($this->courserecord
->id
== SITEID
) {
43 $breadcrumbs = array();
46 $breadcrumbs = array($this->courserecord
->shortname
=> $CFG->wwwroot
.'/course/view.php?id='.$this->courserecord
->id
);
49 $breadcrumbs[get_string('modulenameplural', 'data')] = $CFG->wwwroot
.'/mod/data/index.php?id='.$this->courserecord
->id
;
50 $breadcrumbs[format_string($this->activityrecord
->name
)] = $CFG->wwwroot
.'/mod/data/view.php?id='.$this->modulerecord
->id
;
52 if(!empty($morebreadcrumbs)) {
53 $breadcrumbs = array_merge($breadcrumbs, $morebreadcrumbs);
56 $total = count($breadcrumbs);
59 foreach($breadcrumbs as $text => $href) {
60 if($current++
== $total) {
61 $crumbtext .= ' '.$text;
64 $crumbtext .= ' <a href="'.$href.'">'.$text.'</a> ->';
68 if(empty($morebreadcrumbs) && $this->user_allowed_editing()) {
69 $buttons = '<table><tr><td>'.update_module_button($this->modulerecord
->id
, $this->courserecord
->id
, get_string('modulename', 'data')).'</td>';
70 if(!empty($CFG->showblocksonmodpages
)) {
71 $buttons .= '<td><form '.$CFG->frametarget
.' method="get" action="view.php">'.
72 '<input type="hidden" name="id" value="'.$this->modulerecord
->id
.'" />'.
73 '<input type="hidden" name="edit" value="'.($this->user_is_editing()?
'off':'on').'" />'.
74 '<input type="submit" value="'.get_string($this->user_is_editing()?
'blockseditoff':'blocksediton').'" /></form></td>';
76 $buttons .= '</tr></table>';
81 print_header($title, $this->courserecord
->fullname
, $crumbtext, '', $meta, true, $buttons, navmenu($this->courserecord
, $this->modulerecord
));
86 return PAGE_DATA_VIEW
;