weekly release 3.2.1+
[moodle.git] / lib / form / submitlink.php
blob0cb270c355a0884b51912129c26719485c63c0e4
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.
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/>.
18 /**
19 * submit link type form element
21 * Contains HTML class for a submitting to link
23 * @deprecated since 3.2
24 * @package core_form
25 * @copyright 2006 Jamie Pratt <me@jamiep.org>
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 global $CFG;
30 require_once("$CFG->libdir/form/submit.php");
31 /**
32 * submit link type form element
34 * HTML class for a submitting to link
36 * @package core_form
37 * @category form
38 * @copyright 2006 Jamie Pratt <me@jamiep.org>
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 class MoodleQuickForm_submitlink extends MoodleQuickForm_submit {
42 /** @var string javascript for submitting element's data */
43 var $_js;
45 /** @var string callback function which will be called onclick event */
46 var $_onclick;
48 /**
49 * constructor
51 * @param string $elementName (optional) name of the field
52 * @param string $value (optional) field label
53 * @param string $attributes (optional) Either a typical HTML attribute string or an associative array
55 public function __construct($elementName=null, $value=null, $attributes=null) {
56 debugging('Element type submitlink is deprecated.', DEBUG_DEVELOPER);
57 parent::__construct($elementName, $value, $attributes);
60 /**
61 * Old syntax of class constructor. Deprecated in PHP7.
63 * @deprecated since Moodle 3.1
65 public function MoodleQuickForm_submitlink($elementName=null, $value=null, $attributes=null) {
66 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
67 self::__construct($elementName, $value, $attributes);
70 /**
71 * Returns HTML for submitlink form element.
73 * @return string
75 function toHtml() {
76 $text = $this->_attributes['value'];
78 return "<noscript><div>" . parent::toHtml() . '</div></noscript><script type="text/javascript">' . $this->_js . "\n"
79 . 'document.write(\'<a href="#" onclick="' . $this->_onclick . '">'
80 . $text . "</a>');\n</script>";