[php8-compact] Add in guards into common templates to assit with fixing test failures...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 8 Jun 2021 00:59:14 +0000 (00:59 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 8 Jun 2021 00:59:14 +0000 (00:59 +0000)
templates/CRM/Core/Form/Field.tpl
templates/CRM/Form/validate.tpl
templates/CRM/common/Tagset.tpl
templates/CRM/common/WizardHeader.tpl
templates/CRM/common/customData.tpl
templates/CRM/common/customDataBlock.tpl
templates/CRM/common/formButtons.tpl
templates/CRM/common/jsortable.tpl
templates/CRM/common/showHide.tpl

index d8b8ea42fcc0006c09ae889db7e368f263124359..1d59c0e3c3f675c3a0f0e55e46d69ac0c1dea85b 100644 (file)
@@ -7,18 +7,18 @@
  | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
 *}
-{if $fieldSpec.template}
+{if !empty($fieldSpec.template)}
   {include file=$fieldSpec.template}
 {else}
   <td class="label">{$form.$fieldName.label}
-    {if $fieldSpec.help}{assign var=help value=$fieldSpec.help}{capture assign=helpFile}{if $fieldSpec.help}
+    {if !empty($fieldSpec.help)}{assign var=help value=$fieldSpec.help}{capture assign=helpFile}{if $fieldSpec.help}
       {$fieldSpec.help}
     {else}''{/if}
     {/capture}{help id=$help.id file=$help.file}{/if}
     {if $action == 2 && $fieldSpec.is_add_translate_dialog}{include file='CRM/Core/I18n/Dialog.tpl' table=$entityTable field=$fieldName id=$entityID}{/if}
   </td>
-  <td>{$fieldSpec.pre_html_text}{if $form.$fieldName.html}{$form.$fieldName.html}{else}{$fieldSpec.place_holder}{/if}{$fieldSpec.post_html_text}<br />
-    {if $fieldSpec.description}<span class="description">{$fieldSpec.description}</span>{/if}
-    {if $fieldSpec.documentation_link}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
+  <td>{if !empty($fieldSpec.pre_html_text)}{$fieldSpec.pre_html_text}{/if}{if $form.$fieldName.html}{$form.$fieldName.html}{else}{$fieldSpec.place_holder}{/if}{if !empty($fieldSpec.post_html_text)}{$fieldSpec.post_html_text}{/if}<br />
+    {if !empty($fieldSpec.description)}<span class="description">{$fieldSpec.description}</span>{/if}
+    {if !empty($fieldSpec.documentation_link)}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
   </td>
 {/if}
index 248c0b74ba561bc31b642581929a454af35d98ee..6212a41bd818da312a7810db86da6f912190e3af 100644 (file)
@@ -9,7 +9,7 @@
 *}
 {* Initialize jQuery validate on a form *}
 {* Extra params and functions may be added to the CRM.validate object before this template is loaded *}
-{if !$crm_form_validate_included and $smarty.get.snippet neq 'json' and $form and $form.formClass}
+{if empty($crm_form_validate_included) and !empty($smarty.get.snippet) and $smarty.get.snippet neq 'json' and !empty($form) and !empty($form.formClass)}
   {assign var=crm_form_validate_included value=1}
   {literal}
   <script type="text/javascript">
index b9542431c2af5de1759f8d701a127ace3bd3ba0b..4f79616305c8f11b157ce2e172879026c9ba8a91 100644 (file)
 {if empty($tagsetType)}
   {assign var="tagsetType" value="contact"}
 {/if}
-{if $tableLayout}
+{if !empty($tableLayout)}
   <td colspan="2" class="crm-content-block">
     <table>
 {/if}
+   {if !empty($tagsetInfo)}
     {foreach from=$tagsetInfo.$tagsetType item=tagset}
       {assign var="elemName" value=$tagset.tagsetElementName}
       {if empty($tagsetElementName) or $tagsetElementName eq $elemName}
         {/if}
       {/if}
     {/foreach}
-{if $tableLayout}
+    {/if}
+{if !empty($tableLayout)}
     </table>
   </td>
 {/if}
 
-{if !$skipEntityAction and empty($form.frozen)}
+{if empty($skipEntityAction) and empty($form.frozen)}
   <script type="text/javascript">
     {* Add/remove entity tags via ajax api *}
     {literal}
index 195ae651aa8a4df94c120b82616dc4f859fa9119..01daa52446229dc4c47aa8085008d2058f8ffc47 100644 (file)
@@ -10,7 +10,7 @@
 {if count( $wizard.steps ) > 1}
 {* wizard.style variable is passed by some Wizards to allow alternate styling for progress "bar". *}
 <div id="wizard-steps">
-   <ul class="wizard-bar{if $wizard.style.barClass}-{$wizard.style.barClass}{/if}">
+   <ul class="wizard-bar{if !empty($wizard.style.barClass)}-{$wizard.style.barClass}{/if}">
     {section name=step loop=$wizard.steps}
         {if count ( $wizard.steps ) > 5 }
             {* truncate step titles so header isn't too wide *}
@@ -19,7 +19,7 @@
             {assign var="title" value=$wizard.steps[step].title}
         {/if}
         {* Show each wizard link unless collapsed value is true. Also excluding quest app submit steps. Should create separate WizardHeader for Quest at some point.*}
-        {if !$wizard.steps[step].collapsed && $wizard.steps[step].name NEQ 'Submit' && $wizard.steps[step].name NEQ 'PartnerSubmit'}
+        {if empty($wizard.steps[step].collapsed) && !empty($wizard.steps[step].name) && $wizard.steps[step].name NEQ 'Submit' && $wizard.steps[step].name NEQ 'PartnerSubmit'}
             {assign var=i value=$smarty.section.step.iteration}
             {if $wizard.currentStepNumber > $wizard.steps[step].stepNumber}
                 {if $wizard.steps[step].step}
@@ -64,7 +64,7 @@
     {/section}
    </ul>
 </div>
-{if $wizard.style.showTitle}
+{if !empty($wizard.style.showTitle)}
     <h2>{$wizard.currentStepTitle} {ts 1=$wizard.currentStepNumber 2=$wizard.stepCount}(step %1 of %2){/ts}</h2>
 {/if}
 {/if}
index f52607dafed3a963b0ca0b5c9ec8f087b936d8fc..948d7617862b80af22716ab5c9754d91b1053af9 100644 (file)
       }
 
       {/literal}
-      {if $groupID}
+      {if !empty($groupID)}
         dataUrl += '&groupID=' + '{$groupID}';
       {/if}
-      {if $entityID}
+      {if !empty($entityID)}
         dataUrl += '&entityID=' + '{$entityID}';
       {/if}
-      {if $qfKey}
+      {if !empty($qfKey)}
         dataUrl += '&qf=' + '{$qfKey}';
       {/if}
-      {if $action}
+      {if !empty($action)}
         dataUrl += '&action=' + '{$action}';
       {/if}
       {literal}
index ca3848df706259a29bd4951d286bb27b8469c6bd..eb7c73ccd2886ab10242285c859d7dfa877112a3 100644 (file)
@@ -1,4 +1,4 @@
-{if $customDataType}
+{if !empty($customDataType)}
   <div id="customData"></div>
   {*include custom data js file*}
   {include file="CRM/common/customData.tpl"}
index cd1fd010d9325cc27f80264de8e88f857b26a692..f00a9747839e6c324744a8c25eb8f387c7e1573a 100644 (file)
@@ -30,7 +30,7 @@
 
 {foreach from=$form.buttons item=button key=key name=btns}
   {if $key|substring:0:4 EQ '_qf_'}
-    {if $location}
+    {if !empty($location)}
       {$form.buttons.$key.html|crmReplace:id:"$key-$location"}
     {else}
       {$form.buttons.$key.html}
index e76d7793d3a308933a489c673225744da56380d0..efd1d1d13dd88c74d1d25a0c43e5c215bfbb6dbb 100644 (file)
@@ -27,7 +27,7 @@
     }
 
     // for date sorting see http://wiki.civicrm.org/confluence/display/CRMDOC/Sorting+Date+Fields+in+dataTables+Widget
-    var useAjax = {/literal}{if $useAjax}1{else}0{/if}{literal},
+    var useAjax = {/literal}{if !empty($useAjax)}1{else}0{/if}{literal},
       sourceUrl = '',
       useClass  = 'display',
       tcount = 1,
index e7bc67115ca887274c5a445b432d65b0460818da..b750893acabbdb1521b8f9c191c57b94fdc06818 100644 (file)
@@ -12,5 +12,5 @@
     var showBlocks = new Array({$showBlocks});
     var hideBlocks = new Array({$hideBlocks});
 
-    on_load_init_blocks( showBlocks, hideBlocks{if $elemType EQ 'table-row'}, 'table-row'{/if} );
+    on_load_init_blocks( showBlocks, hideBlocks{if !empty($elemType) and $elemType EQ 'table-row'}, 'table-row'{/if} );
  </script>