source: moodle/trunk/fuentes/blocks/tags/block_tags.php @ 1331

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

File size: 2.6 KB
Line 
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Tags block.
19 *
20 * @package   block_tags
21 * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
22 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25class block_tags extends block_base {
26    public function init() {
27        $this->title = get_string('pluginname', 'block_tags');
28    }
29
30    public function instance_allow_multiple() {
31        return true;
32    }
33
34    public function applicable_formats() {
35        return array('all' => true);
36    }
37
38    public function instance_allow_config() {
39        return true;
40    }
41
42    public function specialization() {
43
44        // Load userdefined title and make sure it's never empty.
45        if (empty($this->config->title)) {
46            $this->title = get_string('pluginname', 'block_tags');
47        } else {
48            $this->title = $this->config->title;
49        }
50    }
51
52    public function get_content() {
53
54        global $CFG, $COURSE, $USER, $SCRIPT, $OUTPUT;
55
56        if (empty($CFG->usetags)) {
57            $this->content = new stdClass();
58            $this->content->text = '';
59            if ($this->page->user_is_editing()) {
60                $this->content->text = get_string('disabledtags', 'block_tags');
61            }
62            return $this->content;
63        }
64
65        if (!isset($this->config)) {
66            $this->config = new stdClass();
67        }
68
69        if (empty($this->config->numberoftags)) {
70            $this->config->numberoftags = 80;
71        }
72
73        if ($this->content !== NULL) {
74            return $this->content;
75        }
76
77        if (empty($this->instance)) {
78            $this->content = '';
79            return $this->content;
80        }
81
82        $this->content = new stdClass;
83        $this->content->text = '';
84        $this->content->footer = '';
85
86        // Get a list of tags.
87
88        require_once($CFG->dirroot.'/tag/locallib.php');
89
90        $this->content->text = tag_print_cloud(null, $this->config->numberoftags, true);
91
92        return $this->content;
93    }
94}
Note: See TracBrowser for help on using the repository browser.