Bootstrap3 - Move warning from Api4Explorer to bundle default
authorTim Otten <totten@civicrm.org>
Fri, 4 Sep 2020 06:56:46 +0000 (23:56 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 4 Sep 2020 07:00:27 +0000 (00:00 -0700)
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
ang/api4Explorer/Explorer.html

index df5328932a0cf65fbdeda3597a37616bc08b4eca..c85abeaec0a1f8cd0df96490cc7629377eac688b 100644 (file)
@@ -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('
+      <div id="bootstrap-theme">
+        <div class="messages warning no-popup collapse">
+          <p>
+            <i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i>
+            <strong>' . ts('Bootstrap theme not found.') . '</strong>
+          </p>
+          <p>' . ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') . '</p>
+        </div>
+      </div>',
+      ['region' => 'page-header']
+    );
+
     CRM_Utils_Hook::alterBundle($bundle);
     self::useRegion($bundle, self::REGION);
     return $bundle;
index b32196dfd55c26e0c72d61ee6e413fadcdfea82b..52b807d4adecd74bc099de2e39e630594b762b85 100644 (file)
@@ -5,15 +5,6 @@
     {{:: ts('CiviCRM APIv4') }}{{ entity ? (' (' + entity + '::' + action + ')') : '' }}
   </h1>
 
-  <!--This warning will show if bootstrap is unavailable. Normally it will be hidden by the bootstrap .collapse class.-->
-  <div class="messages warning no-popup collapse">
-    <p>
-      <i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i>
-      <strong>{{:: ts('Bootstrap theme not found.') }}</strong>
-    </p>
-    <p>{{:: ts('This screen may not work correctly without a bootstrap-based theme such as Shoreditch installed.') }}</p>
-  </div>
-
   <div class="api4-explorer-row">
       <form name="api4-explorer" class="panel panel-default explorer-params-panel">
         <div class="panel-heading">