New tags block
[moodle.git] / blocks / tags / block_tags.php
CommitLineData
d797e50f 1<?PHP //$Id$
2
3class block_tags extends block_base {
4 function init() {
5 $this->version = 2007082800;
6 $this->title = get_string('blocktagstitle', 'tag');
7 }
8
9 function instance_allow_multiple() {
10 return true;
11 }
12
13 function has_config() {
14 return false;
15 }
16
17 function applicable_formats() {
18 return array('all' => true, 'my' => false, 'tag' => false);
19 }
20
21 function instance_allow_config() {
22 return true;
23 }
24
25 function specialization() {
26
27 // load userdefined title and make sure it's never empty
28 if (empty($this->config->title)) {
29 $this->title = get_string('blocktagstitle','tag');
30 } else {
31 $this->title = $this->config->title;
32 }
33 }
34
35 function get_content() {
36
37 global $CFG, $SITE, $COURSE, $USER;
38
39 if (empty($CFG->usetags)) {
40 $this->content->text = '';
41 return $this->content;
42 }
43
44 if (empty($this->config->numberoftags)) {
45 $this->config->numberoftags = 80;
46 }
47
48 if ($this->content !== NULL) {
49 return $this->content;
50 }
51
52 if (empty($this->instance)) {
53 $this->content = '';
54 return $this->content;
55 }
56
57 $this->content = new stdClass;
58 $this->content->footer = '';
59
60 /// Get a list of tags
61
62 include($CFG->dirroot.'/tag/lib.php');
63
64 $this->content->text = print_tag_cloud(popular_tags_count($this->config->numberoftags), false, 170,70, true);
65
66 return $this->content;
67 }
68
69 function instance_config_print() {
70 global $CFG;
71
72 /// set up the numberoftags select field
73 $numberoftags = array();
74 for($i=1;$i<=200;$i++) $numberoftags[$i] = $i;
75
76 if (is_file($CFG->dirroot .'/blocks/'. $this->name() .'/config_instance.html')) {
77 print_simple_box_start('center', '', '', 5, 'blockconfigglobal');
78 include($CFG->dirroot .'/blocks/'. $this->name() .'/config_instance.html');
79 print_simple_box_end();
80 } else {
81 notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me()));
82 }
83 }
84}
85
86?>