See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
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 * Selector target. 19 * 20 * @package tool_usertours 21 * @copyright 2016 Andrew Nicols <andrew@nicols.co.uk> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace tool_usertours\local\target; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use tool_usertours\step; 30 31 /** 32 * Selector target. 33 * 34 * @copyright 2016 Andrew Nicols <andrew@nicols.co.uk> 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class selector extends base { 38 39 /** 40 * Convert the target value to a valid CSS selector for use in the 41 * output configuration. 42 * 43 * @return string 44 */ 45 public function convert_to_css() { 46 return $this->step->get_targetvalue(); 47 } 48 49 /** 50 * Convert the step target to a friendly name for use in the UI. 51 * 52 * @return string 53 */ 54 public function get_displayname() { 55 return get_string('selectordisplayname', 'tool_usertours', $this->step->get_targetvalue()); 56 } 57 58 /** 59 * Get the default title. 60 * 61 * @return string 62 */ 63 public function get_default_title() { 64 return get_string('selector_defaulttitle', 'tool_usertours'); 65 } 66 67 /** 68 * Get the default content. 69 * 70 * @return string 71 */ 72 public function get_default_content() { 73 return get_string('selector_defaultcontent', 'tool_usertours'); 74 } 75 76 /** 77 * Add the target type configuration to the form. 78 * 79 * @param MoodleQuickForm $mform The form to add configuration to. 80 * @return $this 81 */ 82 public static function add_config_to_form(\MoodleQuickForm $mform) { 83 $mform->addElement('text', 'targetvalue_selector', get_string('cssselector', 'tool_usertours')); 84 $mform->setType('targetvalue_selector', PARAM_RAW); 85 $mform->addHelpButton('targetvalue_selector', 'target_selector_targetvalue', 'tool_usertours'); 86 } 87 88 /** 89 * Add the disabledIf values. 90 * 91 * @param MoodleQuickForm $mform The form to add configuration to. 92 */ 93 public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform) { 94 $mform->hideIf('targetvalue_selector', 'targettype', 'noteq', 95 \tool_usertours\target::get_target_constant_for_class(get_class())); 96 } 97 98 /** 99 * Prepare data to submit to the form. 100 * 101 * @param object $data The data being passed to the form 102 */ 103 public function prepare_data_for_form($data) { 104 $data->targetvalue_selector = $this->step->get_targetvalue(); 105 } 106 107 /** 108 * Fetch the targetvalue from the form for this target type. 109 * 110 * @param stdClass $data The data submitted in the form 111 * @return string 112 */ 113 public function get_value_from_form($data) { 114 return $data->targetvalue_selector; 115 } 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body