diff --git a/README.md b/README.md index 10108a1..294dba4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ # Thumbnail links and action block # -[![Build Status](https://travis-ci.org/call-learning/moodle-block-thumblinks_action.svg?branch=master)](https://travis-ci.org/call-learning/moodle-block-thumblinks_action) - +[![Moodle Plugin CI](https://github.com/call-learning/moodle-block_thumblinks_action/actions/workflows/main.yml/badge.svg)](https://github.com/call-learning/moodle-block_thumblinks_action/actions/workflows/main.yml) A simple block to setup a series of 3 thumbnails that are linked other pages. +### Supported Moodle versions + +This block supports several of the latest Moodle versions. + +You can safely use this block with Moodle **4.1**, **4.0**, **3.11**, **3.10**, **3.9** + ## License ## 2020 CALL Learning diff --git a/block_thumblinks_action.php b/block_thumblinks_action.php index 2028576..9d89252 100644 --- a/block_thumblinks_action.php +++ b/block_thumblinks_action.php @@ -18,7 +18,7 @@ * Thumblinks Action block implementation. * * @package block_thumblinks_action - * @copyright 2020 - CALL Learning - Laurent David + * @copyright 2023 - CALL Learning - Laurent David * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,7 +28,6 @@ * Class block_thumblinks_action * * @package block_thumblinks_action - * @copyright 2020 - CALL Learning - Laurent David * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_thumblinks_action extends block_base { @@ -96,7 +95,8 @@ public function get_content() { $urls, $this->config->cta, $this->config->ctatitle, - $this->context->id + $this->context->id, + $this->instance->region ?? '' ) ); } diff --git a/classes/output/thumblinks_action.php b/classes/output/thumblinks_action.php index 24d40da..dd1d57d 100644 --- a/classes/output/thumblinks_action.php +++ b/classes/output/thumblinks_action.php @@ -64,22 +64,31 @@ class thumblinks_action implements renderable, templatable { */ public $ctatitle = ''; + /** + * The place where the block takes place. + * + * @var string $region + */ + public $region = ''; + /** * thumblinks_action constructor. * - * @param array $thumbtitles - * @param array $thumbimages - * @param array $thumburls - * @param moodle_url $cta - * @param string $ctatitle - * @param int $blockcontextid + * @param array $thumbtitles the list of the thumbnails titles + * @param array $thumbimages the list of the thumbnails images + * @param array $thumburls the list of the thumnails urls + * @param moodle_url $cta The url where the call to action button will lead to + * @param string $ctatitle The Title of the call to action button at the bottom of the block + * @param int $blockcontextid the id of the block context + * @param string $region the region of the block, usually given by block_thumblinks_action::instance->region * @throws coding_exception * @throws moodle_exception */ - public function __construct($thumbtitles, $thumbimages, $thumburls, $cta, $ctatitle, $blockcontextid) { + public function __construct($thumbtitles, $thumbimages, $thumburls, $cta, $ctatitle, $blockcontextid, $region) { $thumbtitlecount = empty($thumbtitles) ? 0 : count($thumbtitles); $thumbimgcount = empty($thumbimages) ? 0 : count($thumbimages); $numthumbnails = max($thumbtitlecount, $thumbimgcount); + $this->region = $region; $fs = get_file_storage(); for ($itemi = 0; $itemi < $numthumbnails; $itemi++) { @@ -115,7 +124,8 @@ public function export_for_template(renderer_base $output): array { $exportedvalue = [ 'thumbnails' => $this->thumbnails, 'ctatitle' => $this->ctatitle, - 'cta' => ($this->cta) ? $this->cta->out(false) : '' + 'cta' => ($this->cta) ? $this->cta->out(false) : '', + 'isonside-pre' => $this->region == 'side-pre' ]; return $exportedvalue; } diff --git a/classes/output/thumbnail.php b/classes/output/thumbnail.php index 715360c..9b101d6 100644 --- a/classes/output/thumbnail.php +++ b/classes/output/thumbnail.php @@ -21,12 +21,9 @@ * @copyright 2022 - CALL Learning - Martin CORNU-MANSUY * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -namespace block_thumblinks_action; +namespace block_thumblinks_action\output; use moodle_url; -use renderable; -use renderer_base; -use templatable; /** * A class to represent a thumbnail in the thumblink_action moodle block. diff --git a/edit_form.php b/edit_form.php index c23c06d..03a00e0 100644 --- a/edit_form.php +++ b/edit_form.php @@ -21,13 +21,6 @@ * @copyright 2020 - CALL Learning - Laurent David * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -/** - * Class block_thumblinks_action_edit_form - * - * @copyright 2020 - CALL Learning - Laurent David - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ class block_thumblinks_action_edit_form extends block_edit_form { /** * Form definition diff --git a/templates/thumblinks_action.mustache b/templates/thumblinks_action.mustache index c8b5c23..c3107ae 100644 --- a/templates/thumblinks_action.mustache +++ b/templates/thumblinks_action.mustache @@ -36,9 +36,9 @@