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 the customcert module for 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
 * Creates an upload form on the settings page.
19
 *
20
 * @package    mod_customcert
21
 * @copyright  2013 Mark Nelson <markn@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace mod_customcert;
26
 
27
defined('MOODLE_INTERNAL') || die();
28
 
29
require_once($CFG->libdir.'/adminlib.php');
30
 
31
/**
32
 * Class extends admin setting class to allow/process an uploaded file
33
 *
34
 * @package    mod_customcert
35
 * @copyright  2013 Mark Nelson <markn@moodle.com>
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class admin_setting_link extends \admin_setting_configtext {
39
 
40
    /**
41
     * @var string the link.
42
     */
43
    protected $link;
44
 
45
    /**
46
     * @var string the link name.
47
     */
48
    protected $linkname;
49
 
50
    /**
51
     * The admin_setting_link constructor.
52
     *
53
     * @param string $name
54
     * @param string $visiblename
55
     * @param string $description
56
     * @param string $linkname
57
     * @param mixed|string $link
58
     * @param int|null $defaultsetting
59
     * @param string $paramtype
60
     * @param null $size
61
     */
62
    public function __construct($name, $visiblename, $description, $linkname, $link, $defaultsetting,
63
                                $paramtype = PARAM_RAW, $size=null) {
64
        $this->link = $link;
65
        $this->linkname = $linkname;
66
        parent::__construct($name, $visiblename, $description, $defaultsetting, $paramtype, $size);
67
    }
68
 
69
    /**
70
     * Output the link to the upload image page.
71
     *
72
     * @param mixed $data
73
     * @param string $query
74
     * @return string
75
     */
76
    public function output_html($data, $query = '') {
77
        // Create a dummy variable for this field to avoid being redirected back to the upgrade settings page.
78
        $this->config_write($this->name, '');
79
 
80
        return format_admin_setting($this, $this->visiblename,
81
            \html_writer::link($this->link, $this->linkname), $this->description, true, '', null, $query);
82
    }
83
}