channel_image.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. * Contains class block_rss_client\output\channel_image
  18. *
  19. * @package block_rss_client
  20. * @copyright 2016 Howard County Public School System
  21. * @author Brendan Anderson <brendan_anderson@hcpss.org>
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23. */
  24. namespace block_rss_client\output;
  25. defined('MOODLE_INTERNAL') || die();
  26. /**
  27. * Class to display RSS channel images
  28. *
  29. * @package block_rss_client
  30. * @copyright 2016 Howard County Public School System
  31. * @author Brendan Anderson <brendan_anderson@hcpss.org>
  32. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33. */
  34. class channel_image implements \renderable, \templatable {
  35. /**
  36. * The URL location of the image
  37. *
  38. * @var string
  39. */
  40. protected $url;
  41. /**
  42. * The title of the image
  43. *
  44. * @var string
  45. */
  46. protected $title;
  47. /**
  48. * The URL of the image link
  49. *
  50. * @var string
  51. */
  52. protected $link;
  53. /**
  54. * Contructor
  55. *
  56. * @param \moodle_url $url The URL location of the image
  57. * @param string $title The title of the image
  58. * @param \moodle_url $link The URL of the image link
  59. */
  60. public function __construct(\moodle_url $url, $title, \moodle_url $link = null) {
  61. $this->url = $url;
  62. $this->title = $title;
  63. $this->link = $link;
  64. }
  65. /**
  66. * Export this for use in a mustache template context.
  67. *
  68. * @see templatable::export_for_template()
  69. * @param renderer_base $output
  70. * @return array The data for the template
  71. */
  72. public function export_for_template(\renderer_base $output) {
  73. return array(
  74. 'url' => clean_param($this->url, PARAM_URL),
  75. 'title' => $this->title,
  76. 'link' => clean_param($this->link, PARAM_URL),
  77. );
  78. }
  79. /**
  80. * Set the URL
  81. *
  82. * @param \moodle_url $url
  83. * @return \block_rss_client\output\channel_image
  84. */
  85. public function set_url(\moodle_url $url) {
  86. $this->url = $url;
  87. return $this;
  88. }
  89. /**
  90. * Get the URL
  91. *
  92. * @return \moodle_url
  93. */
  94. public function get_url() {
  95. return $this->url;
  96. }
  97. /**
  98. * Set the title
  99. *
  100. * @param string $title
  101. * @return \block_rss_client\output\channel_image
  102. */
  103. public function set_title($title) {
  104. $this->title = $title;
  105. return $this;
  106. }
  107. /**
  108. * Get the title
  109. *
  110. * @return string
  111. */
  112. public function get_title() {
  113. return $this->title;
  114. }
  115. /**
  116. * Set the link
  117. *
  118. * @param \moodle_url $link
  119. * @return \block_rss_client\output\channel_image
  120. */
  121. public function set_link($link) {
  122. $this->link = $link;
  123. return $this;
  124. }
  125. /**
  126. * Get the link
  127. *
  128. * @return \moodle_url
  129. */
  130. public function get_link() {
  131. return $this->link;
  132. }
  133. }