From d6b0391a2dce1c248b4001f435cb06855aa19cc5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 14 Oct 2021 08:08:43 -0700 Subject: [PATCH] Fixed corruption of carousel attributes and other 'data-' keys. Test added. --- e107_handlers/form_handler.php | 56 ++++++++++++++++++++-------- e107_tests/tests/unit/e_formTest.php | 20 +++++++++- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 11523b4ee..d001c43ba 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -70,6 +70,7 @@ class e_form private $_inline_token; public $_snippets = false; // use snippets or not. - experimental, and may be removed - use at own risk. private $_fontawesome = false; + private $_bootstrap; private $_helptip = 1; /** * @var user_class @@ -96,6 +97,11 @@ class e_form $this->_fontawesome = true; } + if(deftrue('BOOTSTRAP')) + { + $this->_bootstrap = (int) BOOTSTRAP; + } + $this->_helptip = (int) e107::getPref('admin_helptip', 1); } @@ -649,19 +655,35 @@ class e_form $navigation = isset($options['navigation']) ? $options['navigation'] : true; $indicate = isset($options['indicators']) ? $options['indicators'] : true; + $prefix = ($this->_bootstrap > 4) ? 'data-bs-' : 'data-'; + + $att = [ + 'id' => $name, + 'class' => 'carousel slide' + ]; + + $att[$prefix.'ride'] = 'carousel'; + + if(isset($options['wrap'])) + { + $att[$prefix.'wrap'] = (bool) $options['wrap']; + } + + if(isset($options['interval'])) + { + $att[$prefix.'interval'] = (int) $options['interval']; + } + + if(isset($options['pause'])) + { + $att[$prefix.'pause'] = (string) $options['pause']; + } + $start = ' - attributes([ - 'id' => $name, - 'class' => 'carousel slide', - 'data-ride' => 'carousel', - 'data-bs-ride' => 'carousel', - 'data-interval' => isset($options['interval']) ? $options['interval'] : null, - 'data-wrap' => isset($options['wrap']) ? $options['wrap'] : null, - 'data-pause' => isset($options['pause']) ? $options['pause'] : null, - ]) . '>'; + attributes($att) . '>'; if($indicate && (count($array) > 1)) { @@ -674,7 +696,7 @@ class e_form foreach($array as $key=>$tab) { $active = ($c == $act) ? ' class="active"' : ''; - $indicators .= '
  • '; + $indicators .= '
  • '; $c++; } @@ -692,7 +714,7 @@ class e_form foreach($array as $key=>$tab) { $active = ($c == $act) ? ' active' : ''; - $label = !empty($tab['label']) ? ' data-label="'.$tab['label'].'"' : ''; + $label = !empty($tab['label']) ? ' '.$prefix.'label="'.$tab['label'].'"' : ''; $inner .= '