forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagelib.php
91 lines (65 loc) · 2.21 KB
/
pagelib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
require_once($CFG->libdir.'/pagelib.php');
require_once('lib.php');
define('PAGE_TAG_INDEX', 'tag-index');
define('TAG_FORMAT', 'tag');
class page_tag extends page_base {
var $tag_object = NULL;
function get_type() {
return PAGE_TAG_INDEX;
}
function user_allowed_editing() {
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
return has_capability('moodle/tag:editblocks', $systemcontext);
}
function user_is_editing() {
global $USER;
return (!empty($USER->editing));
}
function url_get_path() {
global $CFG;
return $CFG->wwwroot.'/tag/index.php';
}
function url_get_parameters() {
$param = array();
$param['id'] = $this->id;
return $param;
}
function blocks_default_position() {
return BLOCK_POS_LEFT;
}
function blocks_get_positions() {
return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
}
function blocks_move_position(&$instance, $move) {
if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
return BLOCK_POS_RIGHT;
} else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
return BLOCK_POS_LEFT;
}
return $instance->position;
}
function get_format_name() {
return TAG_FORMAT;
}
//----------- printing funtions -----------
function print_header() {
global $USER, $CFG;
$tagname = tag_display_name($this->tag_object);
$navlinks = array();
$navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
$navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
$navigation = build_navigation($navlinks);
$title = get_string('tag', 'tag') .' - '. $tagname;
$button = '';
if( $this->user_allowed_editing() ) {
$button = update_tag_button($this->id);
}
print_header_simple($title, '', $navigation, '', '', '', $button);
}
function print_footer() {
print_footer();
}
}
page_map_class(PAGE_TAG_INDEX, 'page_tag');
?>