Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions block_thumblinks_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Thumblinks Action block implementation.
*
* @package block_thumblinks_action
* @copyright 2020 - CALL Learning - Laurent David <[email protected]>
* @copyright 2023 - CALL Learning - Laurent David <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand All @@ -28,7 +28,6 @@
* Class block_thumblinks_action
*
* @package block_thumblinks_action
* @copyright 2020 - CALL Learning - Laurent David <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_thumblinks_action extends block_base {
Expand Down Expand Up @@ -96,7 +95,8 @@ public function get_content() {
$urls,
$this->config->cta,
$this->config->ctatitle,
$this->context->id
$this->context->id,
$this->instance->region ?? ''
)
);
}
Expand Down
26 changes: 18 additions & 8 deletions classes/output/thumblinks_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions classes/output/thumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
* @copyright 2022 - CALL Learning - Martin CORNU-MANSUY <[email protected]>
* @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.
Expand Down
7 changes: 0 additions & 7 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
* @copyright 2020 - CALL Learning - Laurent David <[email protected]>
* @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 <[email protected]>
* @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
Expand Down
4 changes: 2 additions & 2 deletions templates/thumblinks_action.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

<div id="block-thumblinks-action-{{uniqid}}" class="block-thumblinks-action block-cards">
<div class="container">
<div class="row-fluid">
<div class="row-fluid d-flex {{#isonside-pre}}flex-column{{/isonside-pre}}">
{{#thumbnails}}
<div class="col-sm-12 col-lg-4 pt-3 pt-md-0">
<div class="{{^isonside-pre}}col-sm-12 col-lg-4 pt-3 pt-md-0{{/isonside-pre}}">
<a class="thumbnail mx-2 my-1 d-flex flex-column justify-content-center" {{#image}} style="background-image: url({{.}});" {{/image}} href="{{url}}">
<div class="title w-100 p-1 p-l-2 mt-5">{{ title }}</div>
</a>
Expand Down
3 changes: 2 additions & 1 deletion tests/block_thumblinks_action_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public function test_output_renderer_change_files() {
$block->config->thumbimage,
'https://www.moodle.org',
'Moodle forever',
$block->context->id
$block->context->id,
$block->instance->region ?? ''
);
$exported = $renderable->export_for_template($renderer);
$this->assertStringEndsWith('img4.png', $exported['thumbnails'][0]->image);
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

$plugin->version = 2022111002; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2023020300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2012112900; // Requires this Moodle version.
$plugin->component = 'block_thumblinks_action'; // Full name of the plugin (used for diagnostics).
$plugin->cron = 300;