MDL-10918 Applying Aaron's patch.
[moodle-pu.git] / tag / pagelib.php
blob81bb8dd99127f4f1a15e11172c749b34cfeaff79
1 <?php
3 require_once($CFG->libdir.'/pagelib.php');
4 require_once('lib.php');
6 define('PAGE_TAG_INDEX', 'tag-index');
7 define('TAG_FORMAT', 'tag');
9 class page_tag extends page_base {
11 var $tag_object = NULL;
14 function get_type() {
15 return PAGE_TAG_INDEX;
18 function user_allowed_editing() {
20 $systemcontext = get_context_instance(CONTEXT_SYSTEM);
21 return has_capability('moodle/tag:editblocks', $systemcontext);
25 function user_is_editing() {
26 global $USER;
28 return (!empty($USER->editing));
32 function url_get_path() {
33 global $CFG;
34 return $CFG->wwwroot.'/tag/index.php';
38 function url_get_parameters() {
39 $param = array();
40 $param['id'] = $this->id;
41 return $param;
44 function blocks_default_position() {
45 return BLOCK_POS_LEFT;
48 function blocks_get_positions() {
49 return array(BLOCK_POS_LEFT, BLOCK_POS_RIGHT);
52 function blocks_move_position(&$instance, $move) {
53 if($instance->position == BLOCK_POS_LEFT && $move == BLOCK_MOVE_RIGHT) {
54 return BLOCK_POS_RIGHT;
55 } else if ($instance->position == BLOCK_POS_RIGHT && $move == BLOCK_MOVE_LEFT) {
56 return BLOCK_POS_LEFT;
58 return $instance->position;
61 function get_format_name() {
63 return TAG_FORMAT;
66 //----------- printing funtions -----------
68 function print_header() {
70 global $USER, $CFG;
72 $tag = $this->tag_object;
74 $tagname = tag_display_name($tag);
76 $navlinks = array();
77 $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
78 $navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
80 $navigation = build_navigation($navlinks);
81 $title = get_string('tag', 'tag') . ' - ' . $tagname;
83 $button = '';
84 if( $this->user_allowed_editing() ) {
85 $button = update_tag_button($this->id);
87 print_header_simple($title, '', $navigation, '', '', '', $button);
92 function print_footer() {
94 print_footer();
101 page_map_class(PAGE_TAG_INDEX, 'page_tag');