Replace all instances of check.gif appearing in listings
authorAndrew Hunt <andrew@aghstrategies.com>
Thu, 7 May 2020 16:51:42 +0000 (12:51 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Sun, 10 May 2020 17:24:48 +0000 (13:24 -0400)
17 files changed:
CRM/Campaign/Page/DashBoard.php
CRM/Core/BAO/CustomOption.php
CRM/Core/Page.php
CRM/Core/Smarty/plugins/block.icon.php [new file with mode: 0644]
CRM/Price/Page/Option.php
templates/CRM/Admin/Page/LabelFormats.tpl
templates/CRM/Admin/Page/LocationType.tpl
templates/CRM/Admin/Page/Options.tpl
templates/CRM/Admin/Page/ParticipantStatusType.tpl
templates/CRM/Admin/Page/PaymentProcessor.tpl
templates/CRM/Admin/Page/PaymentProcessorType.tpl
templates/CRM/Admin/Page/PdfFormats.tpl
templates/CRM/Badge/Page/Layout.tpl
templates/CRM/Campaign/Page/Petition.tpl
templates/CRM/Financial/Page/FinancialAccount.tpl
templates/CRM/Mailing/Page/Component.tpl
templates/CRM/Price/Page/Option.tpl

index 1318dd1c576bde5d4de18ed6cf33833847cc49e8..563f85654b9a02b09bef4ce4e0a6b681ed4c06bb 100644 (file)
@@ -312,11 +312,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
         }
         $surveysData[$sid]['isActive'] = $isActive;
 
-        $isDefault = NULL;
-        if ($surveysData[$sid]['is_default']) {
-          $isDefault = '<img src="' . $config->resourceBase . 'i/check.gif" alt="' . ts('Default') . '" />';
-        }
-        $surveysData[$sid]['is_default'] = $isDefault;
+        $surveysData[$sid]['is_default'] = self::crmIcon('fa-check', ts('Default'), $surveysData[$sid]['is_default']);
 
         if ($surveysData[$sid]['result_id']) {
           $resultSet = '<a href= "javascript:displayResultSet( ' . $sid . ',' . "'" . $surveysData[$sid]['title'] . "'" . ', ' . $surveysData[$sid]['result_id'] . ' )" title="' . ts('view result set') . '">' . ts('Result Set') . '</a>';
@@ -415,11 +411,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page {
           $isActive = ts('Yes');
         }
         $petitionsData[$pid]['isActive'] = $isActive;
-        $isDefault = NULL;
-        if ($petitionsData[$pid]['is_default']) {
-          $isDefault = '<img src="' . $config->resourceBase . 'i/check.gif" alt="' . ts('Default') . '" />';
-        }
-        $petitionsData[$pid]['is_default'] = $isDefault;
+        $petitionsData[$pid]['is_default'] = self::crmIcon('fa-check', ts('Default'), $petitionsData[$pid]['is_default']);
 
         $petitionsData[$pid]['action'] = CRM_Core_Action::formLink(self::petitionActionLinks(),
           $action,
index 31c522bc7712ca608c5fe29b82c0c1a25f58926f..7ada06678891739ceb6b36e1b6ca6fd39b7de8ab 100644 (file)
@@ -138,21 +138,12 @@ class CRM_Core_BAO_CustomOption {
       }
 
       if (in_array($field->html_type, ['CheckBox', 'Multi-Select'])) {
-        if (isset($defVal) && in_array($dao->value, $defVal)) {
-          $options[$dao->id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
-        }
-        else {
-          $options[$dao->id]['is_default'] = '';
-        }
+        $isDefault = (isset($defVal) && in_array($dao->value, $defVal));
       }
       else {
-        if ($field->default_value == $dao->value) {
-          $options[$dao->id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
-        }
-        else {
-          $options[$dao->id]['is_default'] = '';
-        }
+        $isDefault = ($field->default_value == $dao->value);
       }
+      $options[$dao->id]['is_default'] = CRM_Core_Page::crmIcon('fa-check', ts('Default'), $isDefault);
       $options[$dao->id]['description'] = $dao->description;
       $options[$dao->id]['class'] = $dao->id . ',' . $class;
       $options[$dao->id]['is_active'] = empty($dao->is_active) ? ts('No') : ts('Yes');
index 251c642d7530cc706eb34c69af356fc92cdc4e3e..b483b1b1f79f6e9cc51dcdb7aa544f6a95de84a5 100644 (file)
@@ -418,4 +418,35 @@ class CRM_Core_Page {
     $this->assign('fields', $dateFields);
   }
 
+  /**
+   * Handy helper to produce the standard markup for an icon with alternative
+   * text for a title and screen readers.
+   *
+   * See also the smarty block function `icon`
+   *
+   * @param string $icon
+   *   The class name of the icon to display.
+   * @param string $text
+   *   The translated text to display.
+   * @param bool $condition
+   *   Whether to display anything at all. This helps simplify code when a
+   *   checkmark should appear if something is true.
+   *
+   * @return string
+   *   The whole bit to drop in.
+   */
+  public static function crmIcon($icon, $text = NULL, $condition = TRUE) {
+    if (!$condition) {
+      return '';
+    }
+    if ($text === NULL || $text === '') {
+      $title = $sr = '';
+    }
+    else {
+      $title = " title=\"$text\"";
+      $sr = "<span class=\"sr-only\">$text</span>";
+    }
+    return "<i class=\"crm-i $icon\"$title></i>$sr";
+  }
+
 }
diff --git a/CRM/Core/Smarty/plugins/block.icon.php b/CRM/Core/Smarty/plugins/block.icon.php
new file mode 100644 (file)
index 0000000..0cdad70
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @author Andrew Hunt, AGH Strategies
+ * $Id$
+ *
+ */
+
+/**
+ * Display an icon with some alternative text.
+ *
+ * This is a wrapper around CRM_Core_Page::icon().
+ *
+ * @param $params
+ *   - condition: if present and falsey, return empty
+ *   - icon: the icon class to display instead of fa-check
+ *
+ * @param $text
+ *   The translated text to include in the icon's title and screen-reader text.
+ *
+ * @param $smarty
+ *
+ * @return string
+ */
+function smarty_block_icon($params, $text, &$smarty) {
+  $condition = array_key_exists('condition', $params) ? $params['condition'] : 1;
+  $icon = $params['icon'] ?? 'fa-check';
+  return CRM_Core_Page::crmIcon($icon, $text, $condition);
+}
index 37d60197cd64b71b835470f2c970e48ebdd93230..14dfa3f65f66ccc8d8f60e2dac3e4c7362c24d13 100644 (file)
@@ -160,12 +160,7 @@ class CRM_Price_Page_Option extends CRM_Core_Page {
           $action -= CRM_Core_Action::DISABLE;
         }
       }
-      if (!empty($customOption[$id]['is_default'])) {
-        $customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
-      }
-      else {
-        $customOption[$id]['is_default'] = '';
-      }
+      $customOption[$id]['is_default'] = CRM_Core_Page::crmIcon('fa-check', ts('Default'), !empty($customOption[$id]['is_default']));
       $customOption[$id]['order'] = $customOption[$id]['weight'];
       $customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action,
         [
index 2baf4ae13d4b707e75fd5cd8c975bfe96cf02de3..d2dd488eea672277a83b3552d3aff4dbce9deab2 100644 (file)
@@ -53,8 +53,7 @@
               <td class="crm-labelFormat-name">{$row.groupName}</td>
               <td class="crm-labelFormat-order nowrap">{$row.weight}</td>
               <td class="crm-labelFormat-description">{$row.grouping}</td>
-              <td class="crm-labelFormat-is_default">{if $row.is_default eq 1}
-              <img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}"/>{/if}&nbsp;</td>
+              <td class="crm-labelFormat-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
               <td class="crm-labelFormat-is_reserved">{if $row.is_reserved eq 1}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
                 &nbsp;</td>
               <td>{$row.action|replace:'xx':$row.id}</td>
index 5d891e12b20e70d13d1375f5aabe32563a2d4ecd..1eb9600caa00c4f765cf88226b7a6802ad8d3205 100644 (file)
@@ -40,7 +40,7 @@
         <td class="crmf-vcard_name crm-editable">{$row.vcard_name}</td>
         <td class="crmf-description crm-editable">{$row.description}</td>
         <td id="row_{$row.id}_status" class="crmf-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
-        <td class="crmf-is_default" >{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}&nbsp;</td>
+        <td class="crmf-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
         <td>{$row.action|replace:'xx':$row.id}</td>
     </tr>
     {/foreach}
index 6c8a0e709dc39eb5f7eb382cbc1ce653b6b49f31..ce99ca6434f70dc2d1cd921647146b3ea9be6f39 100644 (file)
               <td>{$row.financial_account}</td>
             {/if}
             {if $showCounted}
-              <td class="center crm-admin-options-filter">{if $row.filter eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Counted{/ts}" />{/if}</td>
+              <td class="center crm-admin-options-filter">{icon condition=$row.filter}{ts}Counted{/ts}{/icon}</td>
             {/if}
             {if $showVisibility}<td class="crm-admin-visibility_label">{$row.visibility_label}</td>{/if}
             <td class="crm-admin-options-description crm-editable" data-field="description" data-type="textarea">{$row.description}</td>
             <td class="nowrap crm-admin-options-order">{$row.weight}</td>
             {if $showIsDefault}
-              <td class="crm-admin-options-is_default" align="center">{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}&nbsp;</td>
+              <td class="crm-admin-options-is_default" align="center">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
             {/if}
             <td class="crm-admin-options-is_reserved">{if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
             <td class="crm-admin-options-is_active" id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
index 620e411f7102635a510a0ed7d376206a24731e8d..92e1eedec30220ea1a012b2c9e96a8ca5a060f28 100644 (file)
@@ -33,9 +33,9 @@
           <td class="crmf-label crm-editable" data-field="label">{$row.label}</td>
           <td class="crmf-name">{$row.name} ({$row.id})</td>
           <td class="crmf-class {if !$row.is_reserved} crm-editable {/if}" data-type="select">{$row.class}</td>
-          <td class="center crmf-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
+          <td class="center crmf-is_reserved">{icon condition=$row.is_reserved}{ts}Reserved{/ts}{/icon}</td>
         <td id="row_{$row.id}_status" class="crmf-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
-          <td class="center crmf-is_counted">{if $row.is_counted} <img src="{$config->resourceBase}i/check.gif" alt="{ts}Counted{/ts}" />{/if}</td>
+          <td class="center crmf-is_counted">{icon condition=$row.is_counted}{ts}Counted{/ts}{/icon}</td>
           <td class="crmf-weight">{$row.weight}</td>
           <td class="crmf-visibility">{$row.visibility}</td>
           <td>{$row.action|replace:'xx':$row.id}</td>
index 308e508d9e1780770c3eed22a77167b2e25508fe..ba6d55da20f0a335cea327f70853104b13596bc2 100644 (file)
@@ -42,8 +42,7 @@
             <td class="crmf-description">{$row.description}</td>
             <td class="crmf-financial_account_id">{$row.financialAccount}</td>
             <td class="crmf-is_active center">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
-            <td class="crmf-is_default center">
-              {if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}"/>{/if}&nbsp;
+            <td class="crmf-is_default center">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;
             </td>
             <td>{$row.action|replace:'xx':$row.id}</td>
         </tr>
index f8fe04b81dba7cd51ba816616dfc257caaee0396..0526f251a758078732b5a89b79f6b75e033d7e19 100644 (file)
@@ -36,7 +36,7 @@
           <td class="crm-paymentProcessorType-title crm-editable" data-field="title">{$row.title}</td>
             <td class="crm-paymentProcessorType-description">{$row.description}</td>
           <td id="row_{$row.id}_status" class="crm-paymentProcessorType-is_active">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
-            <td class="crm-paymentProcessorType-is_default">{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}&nbsp;</td>
+            <td class="crm-paymentProcessorType-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
           <td>{$row.action}</td>
         </tr>
         {/foreach}
index 5b58ded34b2a0221a04d7db720f556d9ff9a0142..1b419c5752bdd62eabb55d024a971e9ac2eb8849 100644 (file)
@@ -50,7 +50,7 @@
         <tr id="row_{$row.id}" class="crm-pdfFormat {cycle values="odd-row,even-row"} {$row.class}">
             <td class="crm-pdfFormat-name">{$row.name}</td>
             <td class="crm-pdfFormat-description">{$row.description}</td>
-            <td class="crm-pdfFormat-is_default">{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}&nbsp;</td>
+            <td class="crm-pdfFormat-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
           <td class="crm-pdfFormat-order nowrap">{$row.weight}</td>
           <td>{$row.action|replace:'xx':$row.id}</td>
         </tr>
index a2ab0d69d2bfa10b8b8cd52fc3ed1ca96204b6fd..a69b549b34743ce264edd15373539664d27ef015 100644 (file)
               <td id="row_{$row.id}_status" class="crm-badge-layout-is_active">
                 {if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}
               </td>
-              <td class="crm-badge-layout-is_default">
-                {if $row.is_default eq 1}
-                <img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}"/>
-                {/if}&nbsp;
+              <td class="crm-badge-layout-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;
               </td>
               <td>{$row.action|replace:'xx':$row.id}</td>
             </tr>
index 1dfd26a368a86cdd210e2315bbe71f8912ac20b4..85f4423274bb1dc5009947a83f3e5c90b5c9f62d 100644 (file)
@@ -40,7 +40,7 @@
           <td>{$survey.release_frequency}</td>
           <td>{$survey.max_number_of_contacts}</td>
           <td>{$survey.default_number_of_contacts}</td>
-          <td>{if $survey.is_default}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" /> {/if}</td>
+          <td>{icon condition=$survey.is_default}{ts}Default{/ts}{/icon}</td>
           <td id="row_{$survey.id}_status">{if $survey.is_active}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}</td>
      <td class="crm-report-optionList-action">{$survey.action}</td>
         </tr>
index 264ab9ff45b0139980ca38ecaa952176f7294641..95c8044ac6f6ed6c06a89be671aa17770d5778e5 100644 (file)
@@ -52,7 +52,7 @@
           <td>{$row.financial_account_type_id}{if $row.account_type_code} ({$row.account_type_code}){/if}</td>
           <td>{if $row.is_deductible eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
           <td>{if $row.is_reserved eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
-          <td>{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" /> {/if}</td>
+          <td>{icon condition=$row.is_default}{ts}Default{/ts}{/icon}</td>
           <td id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
           <td>{$row.action|replace:'xx':$row.id}</td>
         </tr>
index 25ee1557b7be469bffbf828a20d44dca060965dd..ee7b47880d792c864adba077fdcdfd57b3c4d5b9 100644 (file)
@@ -35,7 +35,7 @@
            <td>{$row.subject}</td>
            <td>{$row.body_html|escape}</td>
            <td>{$row.body_text|escape}</td>
-           <td>{if $row.is_default eq 1}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}&nbsp;</td>
+           <td>{icon condition=$row.is_default}{ts}Default{/ts}{/icon}&nbsp;</td>
      <td id="row_{$row.id}_status">{if $row.is_active eq 1} {ts}Yes{/ts} {else} {ts}No{/ts} {/if}</td>
            <td>{$row.action|replace:'xx':$row.id}</td>
         </tr>
index 0b3ddcbe3391aaf74f75634922ef76a143238722..22f82229a419147ca6c31249985a95f4ab93461c 100644 (file)
@@ -68,7 +68,7 @@
                 <td class="crm-price-option-count">{$row.count}</td>
                 <td class="crm-price-option-max">{$row.max_value}</td>
               {/if}
-              <td class="crm-price-option-is_default">{if $row.is_default}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Default{/ts}" />{/if}</td>
+              <td class="crm-price-option-is_default">{icon condition=$row.is_default}{ts}Default{/ts}{/icon}</td>
               <td class="nowrap crm-price-option-financial-type-id">{$row.financial_type_id}</td>
               <td class="nowrap crm-price-option-order">{$row.weight}</td>
               {if $getTaxDetails}