diff --git a/amd/build/glide.min.js.map b/amd/build/glide.min.js.map index 62d40fb..8741714 100644 --- a/amd/build/glide.min.js.map +++ b/amd/build/glide.min.js.map @@ -1 +1 @@ -{"version":3,"file":"glide.min.js","sources":["../src/glide.js"],"sourcesContent":["/**\n * RSS Thumbnails block\n *\n * @package\n * @copyright 2020 - CALL Learning - Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'block_rss_thumbnails/config'], function($) {\n return function(locator, config) {\n require(['glide'], function(Glide) {\n // Show the slider now we are initialised.\n $(locator).removeClass('d-none');\n new Glide(locator, config).mount();\n });\n };\n});"],"names":["define","$","locator","config","require","Glide","removeClass","mount"],"mappings":";;;;;;;AAOAA,oCAAO,CAAC,SAAU,gCAAgC,SAASC,UAChD,SAASC,QAASC,QACrBC,QAAQ,CAAC,UAAU,SAASC,OAExBJ,EAAEC,SAASI,YAAY,cACnBD,MAAMH,QAASC,QAAQI"} \ No newline at end of file +{"version":3,"file":"glide.min.js","sources":["../src/glide.js"],"sourcesContent":["/**\n * RSS Thumbnails block\n *\n * @package\n * @copyright 2020 - CALL Learning - Laurent David \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'block_rss_thumbnails/config'], function($) {\n return function(locator, config) {\n require(['glide'], function(Glide) {\n // Show the slider now we are initialised.\n $(locator).removeClass('d-none');\n new Glide(locator, config).mount();\n });\n };\n});\n"],"names":["define","$","locator","config","require","Glide","removeClass","mount"],"mappings":";;;;;;;AAOAA,oCAAO,CAAC,SAAU,gCAAgC,SAASC,UAChD,SAASC,QAASC,QACrBC,QAAQ,CAAC,UAAU,SAASC,OAExBJ,EAAEC,SAASI,YAAY,cACnBD,MAAMH,QAASC,QAAQI"} \ No newline at end of file diff --git a/amd/src/glide.js b/amd/src/glide.js index 04e70dc..33b15de 100644 --- a/amd/src/glide.js +++ b/amd/src/glide.js @@ -13,4 +13,4 @@ define(['jquery', 'block_rss_thumbnails/config'], function($) { new Glide(locator, config).mount(); }); }; -}); \ No newline at end of file +}); diff --git a/block_rss_thumbnails.php b/block_rss_thumbnails.php index 03948bb..9b15433 100644 --- a/block_rss_thumbnails.php +++ b/block_rss_thumbnails.php @@ -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'); @@ -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); @@ -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; } @@ -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); @@ -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); } } @@ -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. * diff --git a/edit_form.php b/edit_form.php index 336657b..7da72d5 100644 --- a/edit_form.php +++ b/edit_form.php @@ -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')); diff --git a/templates/block.mustache b/templates/block.mustache index b2edc82..c7c4313 100644 --- a/templates/block.mustache +++ b/templates/block.mustache @@ -30,7 +30,7 @@ Example context (json): { - "carousseldelay" : 10, + "carousseldelay" : 100, "feeds": [ { "title": "News from around my living room", diff --git a/templates/footer.mustache b/templates/footer.mustache new file mode 100644 index 0000000..78b7052 --- /dev/null +++ b/templates/footer.mustache @@ -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 . +}} +{{! + @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" + } +}} + \ No newline at end of file diff --git a/version.php b/version.php index 81c3c8f..0274dbc 100644 --- a/version.php +++ b/version.php @@ -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 = [];