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 * Contains class core_tag\output\tagname 19 * 20 * @package core_tag 21 * @copyright 2016 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_tag\output; 26 27 use context_system; 28 use lang_string; 29 use html_writer; 30 use core_tag_tag; 31 32 /** 33 * Class to preapare a tag name for display. 34 * 35 * @package core_tag 36 * @copyright 2016 Marina Glancy 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class tagname extends \core\output\inplace_editable { 40 41 /** 42 * Constructor. 43 * 44 * @param \stdClass|core_tag_tag $tag 45 */ 46 public function __construct($tag) { 47 $editable = has_capability('moodle/tag:manage', context_system::instance()); 48 $edithint = new lang_string('editname', 'core_tag'); 49 $editlabel = new lang_string('newnamefor', 'core_tag', $tag->rawname); 50 $value = $tag->rawname; 51 $displayvalue = html_writer::link(core_tag_tag::make_url($tag->tagcollid, $tag->rawname), 52 core_tag_tag::make_display_name($tag)); 53 parent::__construct('core_tag', 'tagname', $tag->id, $editable, $displayvalue, $value, $edithint, $editlabel); 54 } 55 56 /** 57 * Updates the value in database and returns itself, called from inplace_editable callback 58 * 59 * @param int $itemid 60 * @param mixed $newvalue 61 * @return \self 62 */ 63 public static function update($itemid, $newvalue) { 64 require_capability('moodle/tag:manage', context_system::instance()); 65 $tag = core_tag_tag::get($itemid, '*', MUST_EXIST); 66 $tag->update(array('rawname' => $newvalue)); 67 return new self($tag); 68 } 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body