Skip to content

Commit

Permalink
Merge pull request #22613 from eileenmcnaughton/notice
Browse files Browse the repository at this point in the history
Fix smarty notices in footer files
  • Loading branch information
colemanw authored Jan 25, 2022
2 parents 3cecad6 + 46de515 commit 04f0066
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CRM/Core/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,15 @@ public function setContext() {
'context',
// FormButtons.tpl (adds buttons to forms).
'linkButtons',
// Required for contactFooter.tpl.
// See CRM_Activity_Form_ActivityTest:testInboundEmailDisplaysWithLineBreaks.
'external_identifier',
'lastModified',
'created_date',
'changeLog',
// Required for footer.tpl,
// See CRM_Activity_Form_ActivityTest:testInboundEmailDisplaysWithLineBreaks.
'footer_status_severity',
];

/**
Expand Down
3 changes: 3 additions & 0 deletions CRM/Core/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class CRM_Core_Page {
'breadcrumb',
'pageTitle',
'isDeleted',
// Required for footer.tpl,
// See ExampleHookTest:testPageOutput.
'footer_status_severity',
];

/**
Expand Down
8 changes: 4 additions & 4 deletions templates/CRM/common/contactFooter.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
{strip}
<div class="crm-footer" id="crm-record-log">
<span class="col1">
{if !empty($external_identifier)}{ts}External ID{/ts}:&nbsp;{$external_identifier}{/if}
{if $external_identifier}{ts}External ID{/ts}:&nbsp;{$external_identifier}{/if}
{if $action !== 2}&nbsp; &nbsp;{ts}Contact ID{/ts}:&nbsp;{$contactId}{/if}
</span>
{if !empty($lastModified)}
{if $lastModified}
{ts}Last Change by{/ts}: <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$lastModified.id`"}">{$lastModified.name}</a> ({$lastModified.date|crmDate}) &nbsp;
{if !empty($changeLog)}
{if $changeLog}
<a href="{crmURL p='civicrm/contact/view' q="reset=1&action=browse&selectedChild=log&cid=`$contactId`"}" class="crm-log-view"><i class="crm-i fa-history" aria-hidden="true"></i> {ts}View Change Log{/ts}</a>
{/if}
{/if}
{if !empty($created_date)}<div class="contact-created-date">{ts}Created{/ts}: {$created_date|crmDate}</div>{/if}
{if $created_date}<div class="contact-created-date">{ts}Created{/ts}: {$created_date|crmDate}</div>{/if}
</div>
{/strip}
2 changes: 1 addition & 1 deletion templates/CRM/common/footer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="crm-footer" id="civicrm-footer">
{crmVersion assign=version}
{ts}Powered by CiviCRM{/ts} <a href="https://download.civicrm.org/about/{$version}">{$version}</a>.
{if !empty($footer_status_severity)}
{if $footer_status_severity}
<span class="status{if $footer_status_severity gt 3} crm-error{elseif $footer_status_severity gt 2} crm-warning{else} crm-ok{/if}">
<a href="{crmURL p='civicrm/a/#/status'}">{$footer_status_message}</a>
</span>
Expand Down
18 changes: 13 additions & 5 deletions tests/phpunit/Civi/Test/ExampleHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Civi\Test;

use Civi\Angular\Page\Main;
use PHPUnit\Framework\TestCase;

/**
* This is an example of a barebones test which implements `HookInterface`. Methods are automatically scanned to
Expand All @@ -17,7 +18,7 @@
*
* @group headless
*/
class ExampleHookTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface {
class ExampleHookTest extends TestCase implements HeadlessInterface, HookInterface {

/**
* @var \CRM_Contact_DAO_Contact
Expand Down Expand Up @@ -81,16 +82,23 @@ public function on_civi_api_prepare(\Civi\API\Event\PrepareEvent $event): void {
$this->tracker['civi.api.prepare'][__FUNCTION__] = TRUE;
}

public function testPageOutput() {
/**
* Basic run test.
*/
public function testPageOutput(): void {
ob_start();
$p = new Main();
$p->run();
$content = ob_get_contents();
ob_end_clean();
$content = ob_get_clean();
$this->assertRegExp('; hook_civicrm_alterContent on_hook_civicrm_alterContent;', $content);
}

public function testGetFields() {
/**
* Test getfields calls hooks.
*
* @throws \CiviCRM_API3_Exception
*/
public function testGetFields(): void {
$this->assertEquals([], $this->tracker['civi.api.resolve']);
$this->assertEquals([], $this->tracker['civi.api.prepare']);
\civicrm_api3('Contact', 'getfields', []);
Expand Down

0 comments on commit 04f0066

Please sign in to comment.