diff --git a/CHANGES.md b/CHANGES.md index 489248206683705fea8d2d2f9b977a4b40d843bf..4d2889cb76b0c068dff00d0ae86cae3691699423 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2020-08-27 - Fixed bug in image area feature if link attribute was left empty. * 2020-08-27 - Fixed regression for commit Added rule to show description border for all users for restricted activities. ### Release v3.8-r3 diff --git a/locallib.php b/locallib.php index a0a6126938534b815e91f6c8416fc481db6b84bf..a215e665558cfc96e2b5d15e02f255a2a88b1fff 100644 --- a/locallib.php +++ b/locallib.php @@ -181,6 +181,10 @@ function theme_boost_campus_get_imageareacontent() { // Get all files from filearea. $files = $fs->get_area_files($systemcontext->id, 'theme_boost_campus', 'imageareaitems', false, 'itemid', false); + // Initialize the array which holds the image links. + $links = []; + // Initialize the array which holds the alt texts. + $alttexts = []; // Only continue processing if there are files in the filearea. if (!empty($files)) { // Get the content from the setting imageareaitemsattributes and explode it to an array by the delimiter "new line". @@ -199,7 +203,7 @@ function theme_boost_campus_get_imageareacontent() { } else { $settings = explode("|", $line); // Check if parameter 2 or 3 is set. - if (!empty($settings[1] || !empty($settings[2]))) { + if (!empty($settings[1]) || !empty($settings[2])) { foreach ($settings as $i => $setting) { $setting = trim($setting); if (!empty($setting)) { diff --git a/tests/behat/theme_boost_campus_additional_layout_settings.feature b/tests/behat/theme_boost_campus_additional_layout_settings.feature index 0dbafc15d19ce20f51e4d6c051f58da4ceef8915..e7b1723d7d7da38a19aeb4275927f86d02bd3631 100644 --- a/tests/behat/theme_boost_campus_additional_layout_settings.feature +++ b/tests/behat/theme_boost_campus_additional_layout_settings.feature @@ -36,6 +36,25 @@ Feature: Configuring the theme_boost_campus plugin for the "Additional Layout Se Then ".imagearea img" "css_element" should exist And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//a[contains(@href, 'http://moodle.org')]" "xpath_element" should exist And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//img[contains(@alt, 'Moodle Logo')]" "xpath_element" should exist + When I navigate to "Appearance > Boost Campus" in site administration + And I click on "Additional Layout Settings" "link" + And I set the field "id_s_theme_boost_campus_imageareaitemsattributes" to "moodle_logo.jpg||Moodle Logo" + And I press "Save changes" + Then ".imagearea img" "css_element" should exist + And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//img[contains(@alt, 'Moodle Logo')]" "xpath_element" should exist + And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//a" "xpath_element" should not exist + When I navigate to "Appearance > Boost Campus" in site administration + And I click on "Additional Layout Settings" "link" + And I set the field "id_s_theme_boost_campus_imageareaitemsattributes" to "moodle_logo.jpg|http://moodle.org" + And I press "Save changes" + Then ".imagearea img" "css_element" should exist + And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//a[contains(@href, 'http://moodle.org')][not(@alt)]" "xpath_element" should exist + When I navigate to "Appearance > Boost Campus" in site administration + And I click on "Additional Layout Settings" "link" + And I set the field "id_s_theme_boost_campus_imageareaitemsattributes" to "moodle_logo.jpg" + And I press "Save changes" + Then "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//img[not(@alt)]" "xpath_element" should exist + And "//div[contains(concat(' ',normalize-space(@class),' '),' imagearea ')]//a" "xpath_element" should not exist # Dependent on setting "Image area items" # This is not testable with behat.