diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index ba0b5a9ec890..46d16e938f09 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -234,6 +234,7 @@ public function formatRemoteExtensionRows($localExtensionRows) { // build list of available downloads $remoteExtensionRows = []; $compat = CRM_Extension_System::getCompatibilityInfo(); + $mapper = CRM_Extension_System::singleton()->getMapper(); foreach ($remoteExtensions as $info) { if (!empty($compat[$info->key]['obsolete'])) { @@ -257,7 +258,7 @@ public function formatRemoteExtensionRows($localExtensionRows) { if (isset($localExtensionRows[$info->key])) { if (array_key_exists('version', $localExtensionRows[$info->key])) { if (version_compare($localExtensionRows[$info->key]['version'], $info->version, '<')) { - $row['is_upgradeable'] = TRUE; + $row['upgradelink'] = $mapper->getUpgradeLink($remoteExtensions[$info->key], $localExtensionRows[$info->key]); } } } diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index ce50f74495d3..59caf165e009 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -535,4 +535,24 @@ public function refresh() { CRM_Extension_System::singleton()->getClassLoader()->refresh(); } + /** + * This returns a formatted string containing an extension upgrade link for the UI. + * @todo We should improve this to return more appropriate text. eg. when an extension is not installed + * it should not say "version xx is installed". + * + * @param array $remoteExtensionInfo + * @param array $localExtensionInfo + * + * @return string + */ + public function getUpgradeLink($remoteExtensionInfo, $localExtensionInfo) { + if (!empty($remoteExtensionInfo) && version_compare($localExtensionInfo['version'], $remoteExtensionInfo->version, '<')) { + return ts('Version %1 is installed. Upgrade to version %3.', [ + 1 => $localExtensionInfo['version'], + 2 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id={$localExtensionInfo['key']}&key={$localExtensionInfo['key']}") . '"', + 3 => $remoteExtensionInfo->version, + ]); + } + } + } diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 29e0a2fd6a85..6b5f4f1778c4 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -620,23 +620,16 @@ public function checkExtensions() { case CRM_Extension_Manager::STATUS_INSTALLED: if (!empty($remotes[$key]) && version_compare($row['version'], $remotes[$key]->version, '<')) { - $updates[] = ts('%1 (%2) version %3 is installed. Upgrade to version %5.', [ - 1 => $row['label'] ?? NULL, - 2 => $key, - 3 => $row['version'], - 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"', - 5 => $remotes[$key]->version, - ]); + $updates[] = $row['label'] . ': ' . $mapper->getUpgradeLink($remotes[$key], $row); } else { if (empty($row['label'])) { $okextensions[] = $key; } else { - $okextensions[] = ts('%1 (%2) version %3', [ + $okextensions[] = ts('%1: Version %2', [ 1 => $row['label'], - 2 => $key, - 3 => $row['version'], + 2 => $row['version'], ]); } } diff --git a/templates/CRM/Admin/Page/Extensions/Main.tpl b/templates/CRM/Admin/Page/Extensions/Main.tpl index 5e87242afb5a..881d1a4d0ce9 100644 --- a/templates/CRM/Admin/Page/Extensions/Main.tpl +++ b/templates/CRM/Admin/Page/Extensions/Main.tpl @@ -22,9 +22,8 @@ Depends: CRM/common/enableDisableApi.tpl and CRM/common/jsortable.tpl  {$row.label}
{$row.description} - {if $extAddNewEnabled && $remoteExtensionRows[$extKey] && $remoteExtensionRows[$extKey].is_upgradeable} - {capture assign='upgradeURL'}{crmURL p='civicrm/admin/extensions' q="action=update&id=$extKey&key=$extKey"}{/capture} -
{ts 1=$upgradeURL}Version {$remoteExtensionRows[$extKey].version} is available. Upgrade{/ts}
+ {if $extAddNewEnabled && $remoteExtensionRows[$extKey] && $remoteExtensionRows[$extKey].upgradelink} +
{$remoteExtensionRows[$extKey].upgradelink}
{/if} {$row.statusLabel} {if $row.upgradable}
({ts}Outdated{/ts}){/if}