Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   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 block_rss_client\output\footer
  19   *
  20   * @package   block_rss_client
  21   * @copyright 2015 Howard County Public School System
  22   * @author    Brendan Anderson <brendan_anderson@hcpss.org>
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace block_rss_client\output;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  /**
  31   * Class to help display an RSS Block footer
  32   *
  33   * @package   block_rss_client
  34   * @copyright 2015 Howard County Public School System
  35   * @author    Brendan Anderson <brendan_anderson@hcpss.org>
  36   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class footer implements \renderable, \templatable {
  39  
  40      /**
  41       * The link provided in the RSS channel
  42       *
  43       * @var \moodle_url|null
  44       */
  45      protected $channelurl;
  46  
  47      /**
  48       * Link to manage feeds, only provided if a feed has failed.
  49       *
  50       * @var \moodle_url|null
  51       */
  52      protected $manageurl = null;
  53  
  54      /**
  55       * Constructor
  56       *
  57       * @param \moodle_url $channelurl (optional) The link provided in the RSS channel
  58       */
  59      public function __construct($channelurl = null) {
  60          $this->channelurl = $channelurl;
  61      }
  62  
  63      /**
  64       * Set the channel url
  65       *
  66       * @param \moodle_url $channelurl
  67       * @return \block_rss_client\output\footer
  68       */
  69      public function set_channelurl(\moodle_url $channelurl) {
  70          $this->channelurl = $channelurl;
  71  
  72          return $this;
  73      }
  74  
  75      /**
  76       * Record the fact that there is at least one failed feed (and the URL for viewing
  77       * these failed feeds).
  78       *
  79       * @param \moodle_url $manageurl the URL to link to for more information
  80       */
  81      public function set_failed(\moodle_url $manageurl) {
  82          $this->manageurl = $manageurl;
  83      }
  84  
  85      /**
  86       * Get the channel url
  87       *
  88       * @return \moodle_url
  89       */
  90      public function get_channelurl() {
  91          return $this->channelurl;
  92      }
  93  
  94      /**
  95       * Export context for use in mustache templates
  96       *
  97       * @see templatable::export_for_template()
  98       * @param renderer_base $output
  99       * @return stdClass
 100       */
 101      public function export_for_template(\renderer_base $output) {
 102          $data = new \stdClass();
 103          $data->channellink = clean_param($this->channelurl, PARAM_URL);
 104          if ($this->manageurl) {
 105              $data->hasfailedfeeds = true;
 106              $data->manageurl = clean_param($this->manageurl, PARAM_URL);
 107          }
 108  
 109          return $data;
 110      }
 111  }