See Release Notes
Long Term Support Release
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\tagfeed 19 * 20 * @package core_tag 21 * @copyright 2015 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 templatable; 28 use renderer_base; 29 use stdClass; 30 31 /** 32 * Class to display feed of tagged items 33 * 34 * @package core_tag 35 * @copyright 2015 Marina Glancy 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class tagfeed implements templatable { 39 40 /** @var array */ 41 protected $items; 42 43 /** 44 * Constructor 45 * 46 * Usually the most convenient way is to call constructor without arguments and 47 * add items later using add() method. 48 * 49 * @param array $items 50 */ 51 public function __construct($items = array()) { 52 $this->items = array(); 53 if ($items) { 54 foreach ($items as $item) { 55 $item = (array)$item + array('img' => '', 'heading' => '', 'details' => ''); 56 $this->add($item['img'], $item['heading'], $item['details']); 57 } 58 } 59 } 60 61 /** 62 * Adds one item to the tagfeed 63 * 64 * @param string $img HTML code representing image (or image wrapped in a link), note that 65 * core_tag/tagfeed template expects image to be 35x35 px 66 * @param string $heading HTML for item heading 67 * @param string $details HTML for item details (keep short) 68 */ 69 public function add($img, $heading, $details = '') { 70 $this->items[] = array('img' => $img, 'heading' => $heading, 'details' => $details); 71 } 72 73 /** 74 * Export this data so it can be used as the context for a mustache template. 75 * 76 * @param renderer_base $output 77 * @return stdClass 78 */ 79 public function export_for_template(renderer_base $output) { 80 return array('items' => $this->items); 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body