Skip to content
Snippets Groups Projects
Commit d7146fa4 authored by Kathrin Osswald's avatar Kathrin Osswald
Browse files

Fixed bug that multiple imagearea rows are displayed dependent on the amount of uploaded images.

parent 29880ac6
Branches hsh_v3.10-r6
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@ moodle-theme_boost_campus
Changes
-------
### Unreleased
* 2020-09-01 - Fixed bug that multiple imagearea rows are displayed dependent on the amount of uploaded images.
### Release v3.8-r4
* 2020-08-27 - Fixed bug in image area feature if link attribute was left empty.
......
......@@ -24,6 +24,7 @@
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/theme/boost_campus/locallib.php');
$imageareafiles = theme_boost_campus_get_imageareacontent();
......@@ -31,4 +32,7 @@ $imageareafiles = theme_boost_campus_get_imageareacontent();
// Only proceed if received array is not empty.
if (!empty($imageareafiles)) {
$templatecontext['imageareafiles'] = $imageareafiles;
$templatecontext['hasimagearea'] = true;
} else {
$templatecontext['hasimagearea'] = false;
}
......@@ -258,7 +258,8 @@ function theme_boost_campus_get_imageareacontent() {
$themeboostcampuscache->set('imageareadata', $imageareacache);
return $imageareacache;
} else { // If no images are uploaded, then cache an empty array.
return $themeboostcampuscache->set('imageareadata', array());
$themeboostcampuscache->set('imageareadata', array());
return array();
}
}
}
......
......@@ -20,6 +20,7 @@
Boost_campus imagearea layout template.
Context variables required for this template:
* hasimagearea - true if images have been uploaded.
* imageareafiles - array of uploaded images.
* linkpath - true if image has a link defined in setting imageareaitemslink.
* filepath - the path where the uploaded image is stored.
......@@ -27,6 +28,7 @@
Example context (json):
{
"hasimagearea" : true,
"imageareafiles": {
"filepath": "/pix/moodlelogo.png",
"linkpath": "http://moodle.org"
......@@ -36,10 +38,10 @@
}}
{{# imageareafiles }}
{{#hasimagearea}}
<div class="imagearea d-flex justify-content-center flex-wrap pb-3 bg-dark">
{{#imageareafiles}}
{{#linkpath}}<a href="{{linkpath}}">{{/linkpath}}<img src="{{filepath}}" class="mt-3" {{#alttext}} alt="{{alttext}}"{{/alttext}}>{{#linkpath}}</a>{{/linkpath}}
{{/imageareafiles}}
</div>
{{/ imageareafiles }}
{{/hasimagearea}}
......@@ -16,13 +16,19 @@ Feature: Configuring the theme_boost_campus plugin for the "Additional Layout Se
| teacher1 | C1 | editingteacher |
@javascript @_file_upload
Scenario: Add "Image area items"
Scenario: Add "Image area items" and delete them again
When I log in as "admin"
And I navigate to "Appearance > Boost Campus" in site administration
And I click on "Additional Layout Settings" "link"
And I upload "theme/boost_campus/tests/fixtures/moodle_logo.jpg" file to "Image area items" filemanager
And I press "Save changes"
Then ".imagearea img" "css_element" should exist
And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//img[contains(@src, '/pluginfile.php/1/theme_boost_campus/imageareaitems/0/moodle_logo.jpg')]" "xpath_element" should exist
When I navigate to "Appearance > Boost Campus" in site administration
And I click on "Additional Layout Settings" "link"
And I delete "moodle_logo.jpg" from "Image area items" filemanager
And I press "Save changes"
Then ".imagearea" "css_element" should not exist
# Dependent on setting "Image area items"
@javascript @_file_upload
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment