From d853edea874fcb599205fe890ba0e6bd6bc3e3d0 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 3 Sep 2020 23:56:46 -0700 Subject: [PATCH] Bootstrap3 - Move warning from Api4Explorer to bundle default The Api4Explorer page has a neat trick - if (by any means) you manage to have Bootstrap3 active within the body of this Civi page, then it will display a warning. This patch moves the trick to be part of the `bootstrap3` bundle, which means that it will be applied to any page where `bootstrap3` is activated. --- CRM/Core/Resources/Common.php | 26 +++++++++++++++++++++----- ang/api4Explorer/Explorer.html | 9 --------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/CRM/Core/Resources/Common.php b/CRM/Core/Resources/Common.php index df5328932a..c85abeaec0 100644 --- a/CRM/Core/Resources/Common.php +++ b/CRM/Core/Resources/Common.php @@ -25,11 +25,27 @@ class CRM_Core_Resources_Common { * @return \CRM_Core_Resources_Bundle */ public static function createBootstrap3Bundle($name) { - $bundle = new CRM_Core_Resources_Bundle($name); - $bundle->addStyleFile('civicrm', 'css/bootstrap3.css'); - $bundle->addScriptFile('civicrm', 'js/bootstrap3.js', [ - 'translate' => FALSE, - ]); + $bundle = new CRM_Core_Resources_Bundle($name, ['script', 'scriptFile', 'scriptUrl', 'settings', 'style', 'styleFile', 'styleUrl', 'markup']); + // Leave it to the theme/provider to register specific resources. + // $bundle->addStyleFile('civicrm', 'css/bootstrap3.css'); + // $bundle->addScriptFile('civicrm', 'js/bootstrap3.js', [ + // 'translate' => FALSE, + //]); + + // This warning will show if bootstrap is unavailable. Normally it will be hidden by the bootstrap .collapse class. + $bundle->addMarkup(' +
+
+

+ + ' . ts('Bootstrap theme not found.') . ' +

+

' . ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') . '

+
+
', + ['region' => 'page-header'] + ); + CRM_Utils_Hook::alterBundle($bundle); self::useRegion($bundle, self::REGION); return $bundle; diff --git a/ang/api4Explorer/Explorer.html b/ang/api4Explorer/Explorer.html index b32196dfd5..52b807d4ad 100644 --- a/ang/api4Explorer/Explorer.html +++ b/ang/api4Explorer/Explorer.html @@ -5,15 +5,6 @@ {{:: ts('CiviCRM APIv4') }}{{ entity ? (' (' + entity + '::' + action + ')') : '' }} - -
-

- - {{:: ts('Bootstrap theme not found.') }} -

-

{{:: ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') }}

-
-
-- 2.25.1