Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 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 * Contains class used to prepare a popup notification for display. 19 * 20 * @package message_popup 21 * @copyright 2016 Ryan Wyllie <ryan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace message_popup\output; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 require_once($CFG->dirroot . '/message/lib.php'); 30 31 use renderable; 32 use templatable; 33 use moodle_url; 34 use core_user; 35 36 /** 37 * Class to prepare a popup notification for display. 38 * 39 * @package message_popup 40 * @copyright 2016 Ryan Wyllie <ryan@moodle.com> 41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 42 */ 43 class popup_notification implements templatable, renderable { 44 45 /** 46 * @var \stdClass The notification. 47 */ 48 protected $notification; 49 50 /** 51 * Constructor. 52 * 53 * @param \stdClass $notification 54 */ 55 public function __construct($notification) { 56 $this->notification = $notification; 57 } 58 59 public function export_for_template(\renderer_base $output) { 60 $context = clone $this->notification; 61 $context->timecreatedpretty = get_string('ago', 'message', format_time(time() - $context->timecreated)); 62 $context->text = message_format_message_text($context); 63 $context->read = $context->timeread ? true : false; 64 65 // Need to strip any HTML from these. 66 $context->subject = clean_param($context->subject, PARAM_TEXT); 67 $context->contexturlname = clean_param($context->contexturlname, PARAM_TEXT); 68 $context->shortenedsubject = shorten_text($context->subject, 125); 69 70 if (!empty($context->component) && substr($context->component, 0, 4) == 'mod_') { 71 $iconurl = $output->image_url('monologo', $context->component); 72 } else { 73 $iconurl = $output->image_url('i/marker', 'core'); 74 } 75 76 $context->iconurl = $iconurl->out(); 77 78 return $context; 79 } 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body