Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * unilabel module.
19
 *
20
 * @package     mod_unilabel
21
 * @author      Andreas Grabs <info@grabs-edv.de>
22
 * @copyright   2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
namespace mod_unilabel\search;
27
 
28
/**
29
 * Search area for mod_unilabel activities.
30
 *
31
 * Although there is no name field the intro value is stored internally, so no need
32
 * to overwrite self::get_document.
33
 * @package     mod_unilabel
34
 * @author      Andreas Grabs <info@grabs-edv.de>
35
 * @copyright   2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
36
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class activity extends \core_search\base_activity {
39
    /**
40
     * Returns true if this area uses file indexing.
41
     *
42
     * @return bool
43
     */
44
    public function uses_file_indexing() {
45
        return true;
46
    }
47
 
48
    /**
49
     * Overwritten as unilabels are displayed in-course.
50
     *
51
     * @param  \core_search\document $doc
52
     * @return \moodle_url
53
     */
54
    public function get_doc_url(\core_search\document $doc) {
55
        // Get correct URL to section that contains unilabel, from course format.
56
        $cminfo = $this->get_cm($this->get_module_name(), (string) $doc->get('itemid'), $doc->get('courseid'));
57
        $format = course_get_format($cminfo->get_course());
58
        $url    = $format->get_view_url($cminfo->sectionnum);
59
 
60
        // Add the ID of the unilabel to the section URL.
61
        $url->set_anchor('module-' . $cminfo->id);
62
 
63
        return $url;
64
    }
65
 
66
    /**
67
     * Overwritten as unilabels are displayed in-course. Link to the course.
68
     *
69
     * @param  \core_search\document $doc
70
     * @return \moodle_url
71
     */
72
    public function get_context_url(\core_search\document $doc) {
73
        return new \moodle_url('/course/view.php', ['id' => $doc->get('courseid')]);
74
    }
75
}