Fixes bug MDL-8234, "New groups code & AS keyword"
[moodle-pu.git] / mod / data / pagelib.php
blob2b84d2597a0f0afeb261cce16995a88ab9d3b2f2
1 <?php // $Id$
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);
14 /**
15 * Class that models the behavior of a data
17 * @author Jon Papaioannou
18 * @package pages
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) {
32 global $USER, $CFG;
34 $this->init_full();
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();
45 else {
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);
57 $current = 1;
58 $crumbtext = '';
59 foreach($breadcrumbs as $text => $href) {
60 if($current++ == $total) {
61 $crumbtext .= ' '.$text;
63 else {
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>';
78 else {
79 $buttons = '&nbsp;';
81 print_header($title, $this->courserecord->fullname, $crumbtext, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord));
85 function get_type() {
86 return PAGE_DATA_VIEW;