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 * Provides {@see \core_contentbank\form\edit_content} class. 19 * 20 * @package core_contentbank 21 * @copyright 2020 Victor Deniz <victor@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_contentbank\form; 26 27 use moodleform; 28 29 defined('MOODLE_INTERNAL') || die(); 30 31 require_once($CFG->libdir.'/formslib.php'); 32 33 /** 34 * Defines the form for editing a content. 35 * 36 * @package core_contentbank 37 * @copyright 2020 Victor Deniz <victor@moodle.com> 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 abstract class edit_content extends moodleform { 41 42 /** @var int Context the content belongs to. */ 43 protected $contextid; 44 45 /** @var string Content type plugin name. */ 46 protected $plugin; 47 48 /** @var int Content id in the content bank. */ 49 protected $id; 50 51 /** 52 * Constructor. 53 * 54 * @param string $action The action attribute for the form. 55 * @param array $customdata Data to set during instance creation. 56 * @param string $method Form method. 57 */ 58 public function __construct(string $action = null, array $customdata = null, string $method = 'post') { 59 parent::__construct($action, $customdata, $method); 60 $this->contextid = $customdata['contextid']; 61 $this->plugin = $customdata['plugin']; 62 $this->id = $customdata['id']; 63 64 $mform =& $this->_form; 65 $mform->addElement('hidden', 'contextid', $this->contextid); 66 $this->_form->setType('contextid', PARAM_INT); 67 68 $mform->addElement('hidden', 'plugin', $this->plugin); 69 $this->_form->setType('plugin', PARAM_PLUGIN); 70 71 $mform->addElement('hidden', 'id', $this->id); 72 $this->_form->setType('id', PARAM_INT); 73 } 74 75 /** 76 * Overrides formslib's add_action_buttons() method. 77 * 78 * 79 * @param bool $cancel 80 * @param string|null $submitlabel 81 * 82 * @return void 83 */ 84 public function add_action_buttons($cancel = true, $submitlabel = null): void { 85 if (is_null($submitlabel)) { 86 $submitlabel = get_string('save'); 87 } 88 parent::add_action_buttons($cancel, $submitlabel); 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body