Skip to content
2 changes: 1 addition & 1 deletion amd/build/glide.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/src/glide.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ define(['jquery', 'block_rss_thumbnails/config'], function($) {
new Glide(locator, config).mount();
});
};
});
});
36 changes: 7 additions & 29 deletions block_rss_thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,16 @@ class block_rss_thumbnails extends block_base {
/** @var int The maximum number of item entries for a feed by default */
const DEFAULT_MAX_ENTRIES = 5;


/** @var bool Track whether any of the output feeds have recorded failures */
private $hasfailedfeeds = false;

/** @var int Defines the delay between two slides of the caroussel (ms) */
private $carousseldelay = self::DEFAULT_CAROUSSEL_DELAY;

/** @var int Defines the number of maximum feeds in the thumbnail */
private $maxentries = self::DEFAULT_MAX_ENTRIES;


/**
* Init function
*
* @param int|null $carousseldelay
* @throws coding_exception
*/
public function init(?int $carousseldelay = null): void {

if (!empty($carousseldelay)) {
$this->carousseldelay = $carousseldelay;
}
public function init(): void {

$this->title = get_string('pluginname', 'block_rss_thumbnails');

Expand Down Expand Up @@ -114,8 +102,8 @@ public function get_content() {

return $this->content;
}

$block = new block($this->get_carousseldelay());
$carousseldelay = $this->config->carousseldelay ?? self::DEFAULT_CAROUSSEL_DELAY;
$block = new block($carousseldelay);

if (!empty($this->config->rssid)) {
list($rssidssql, $params) = $DB->get_in_or_equal($this->config->rssid);
Expand All @@ -136,8 +124,8 @@ public function get_content() {
$renderer = $this->page->get_renderer('block_rss_thumbnails');

$this->content = (object) [
'text' => $renderer->render($block, $rssfeeds),
'footer' => $footer ?? ''
'text' => $renderer->render($block, $rssfeeds),
'footer' => $footer ? $renderer->render($footer) : ''
];
return $this->content;
}
Expand All @@ -154,8 +142,7 @@ protected function get_footer($feedrecords, $maxentries = self::DEFAULT_MAX_ENTR

if (!empty($this->config->show_channel_link)) {
$feedrecord = array_pop($feedrecords);
$feed = feed_creator::create_feed(file_get_contents($feedrecord->url), $maxentries);
$channellink = new moodle_url($feed->get_link());
$channellink = new moodle_url($feedrecord->url);

if (!empty($channellink)) {
$footer = new footer($channellink);
Expand All @@ -170,7 +157,7 @@ protected function get_footer($feedrecords, $maxentries = self::DEFAULT_MAX_ENTR
$footer = new footer();
}
$manageurl = new moodle_url('/blocks/rss_thumbnails/managefeeds.php',
['courseid' => $this->page->course->id]);
['courseid' => $this->page->course->id]);
$footer->set_failed($manageurl);
}
}
Expand Down Expand Up @@ -211,15 +198,6 @@ public function format_title($title, $max = 64): string {
return (core_text::strlen($title) <= $max) ? $title : core_text::substr($title, 0, $max - 3) . '...';
}

/**
* Gets the caroussel delay between two slides
*
* @return int
*/
public function get_carousseldelay(): int {
return $this->carousseldelay;
}

/**
* Checks wether the configuration of the block is valid or not.
*
Expand Down
2 changes: 1 addition & 1 deletion edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function specific_definition($mform) {
get_string('choosefeedlabel', 'block_rss_thumbnails'),
$rssfeeds
);
$select->setMultiple(true);
$select->setMultiple(false);
} else {
$mform->addElement('static', 'config_rssid_no_feeds', get_string('choosefeedlabel', 'block_rss_thumbnails'),
get_string('nofeeds', 'block_rss_thumbnails'));
Expand Down
2 changes: 1 addition & 1 deletion templates/block.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

Example context (json):
{
"carousseldelay" : 10,
"carousseldelay" : 100,
"feeds": [
{
"title": "News from around my living room",
Expand Down
43 changes: 43 additions & 0 deletions templates/footer.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{!
This file is part of Moodle - http://moodle.org/

Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template block_rss_thumbnails/block

Template which defines an RSS Feeds block

Classes required for JS:
* none

Data attributes required for JS:
* none

Context variables required for this template:
* feeds - array: An array of RSS feeds.

Example context (json):
{
"channellink": "https://moodle.org",
"hasfailedfeeds": true,
"manageurl": "https://example.com"
}
}}
<div id="footer">
<a href="{{ channellink }}">Source site</a>
{{#hasfailedfeeds}}
<p>You have some failed feeds. You can <a href="{{manageurl}}">manage your feeds</a> to try to fix this.</p>
{{/hasfailedfeeds}}
</div>
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2022120700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2022120900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2012112900; // Requires this Moodle version.
$plugin->release = 1.0;
$plugin->release = 1.1;
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'block_rss_thumbnails'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = [];