mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
MDL-26675 block_rss_client: Add a new feed in the RSS block form
The patch added a couple of things: - Add a new feed in the RSS block form - Make the image responsive to the parent container - Each feed now includes a channel link
This commit is contained in:
parent
fd487cd3f2
commit
b3e8993353
10 changed files with 242 additions and 48 deletions
|
@ -44,6 +44,13 @@ class feed implements \renderable, \templatable {
|
|||
*/
|
||||
protected $title = null;
|
||||
|
||||
/**
|
||||
* The feed's channel link.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected ?string $channellink;
|
||||
|
||||
/**
|
||||
* An array of renderable feed items
|
||||
*
|
||||
|
@ -78,11 +85,13 @@ class feed implements \renderable, \templatable {
|
|||
* @param string $title The title of the RSS feed
|
||||
* @param boolean $showtitle Whether to show the title
|
||||
* @param boolean $showimage Whether to show the channel image
|
||||
* @param string|null $channellink The channel link of the RSS feed
|
||||
*/
|
||||
public function __construct($title, $showtitle = true, $showimage = true) {
|
||||
public function __construct($title, $showtitle = true, $showimage = true, ?string $channellink = null) {
|
||||
$this->title = $title;
|
||||
$this->showtitle = $showtitle;
|
||||
$this->showimage = $showimage;
|
||||
$this->channellink = $channellink;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +106,7 @@ class feed implements \renderable, \templatable {
|
|||
'title' => $this->showtitle ? $this->title : null,
|
||||
'image' => null,
|
||||
'items' => array(),
|
||||
'channellink' => $this->channellink ?? null,
|
||||
);
|
||||
|
||||
if ($this->showimage && $this->image) {
|
||||
|
@ -131,6 +141,15 @@ class feed implements \renderable, \templatable {
|
|||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the feed channel link.
|
||||
*
|
||||
* @param \moodle_url|null $channellink the URL to the channel website.
|
||||
*/
|
||||
public function set_channellink(?\moodle_url $channellink) {
|
||||
$this->channellink = $channellink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an RSS item
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue