Replace extension key with label during install/upgrade/disable/uninstall
authorMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 11 Aug 2021 14:26:20 +0000 (15:26 +0100)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 11 Aug 2021 21:06:15 +0000 (22:06 +0100)
CRM/Admin/Form/Extensions.php
templates/CRM/Admin/Page/ExtensionDetails.tpl

index dc7687671bfa0af9ec60bd74997c64493e8842f8..7ee7df2f91a2f4dfc97a9752717cd4b920f35398 100644 (file)
  */
 class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
 
+  /**
+   * @var string
+   */
+  private $_key;
+
+  /**
+   * @var string
+   */
+  private $label;
+
   /**
    * Form pre-processing.
    */
@@ -39,6 +49,7 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
     if (!CRM_Utils_Type::validate($this->_key, 'ExtensionKey') && !empty($this->_key)) {
       throw new CRM_Core_Exception('Extension Key does not match expected standard');
     }
+    $this->label = $remoteExtensionRows[$this->_key]['label'] ?? $this->_key;
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse');
     $session->pushUserContext($url);
@@ -86,35 +97,35 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form {
       case CRM_Core_Action::ADD:
         $buttonName = ts('Install');
         $title = ts('Install "%1"?', [
-          1 => $this->_key,
+          1 => $this->label,
         ]);
         break;
 
       case CRM_Core_Action::UPDATE:
         $buttonName = ts('Download and Install');
         $title = ts('Download and Install "%1"?', [
-          1 => $this->_key,
+          1 => $this->label,
         ]);
         break;
 
       case CRM_Core_Action::DELETE:
         $buttonName = ts('Uninstall');
         $title = ts('Uninstall "%1"?', [
-          1 => $this->_key,
+          1 => $this->label,
         ]);
         break;
 
       case CRM_Core_Action::ENABLE:
         $buttonName = ts('Enable');
         $title = ts('Enable "%1"?', [
-          1 => $this->_key,
+          1 => $this->label,
         ]);
         break;
 
       case CRM_Core_Action::DISABLE:
         $buttonName = ts('Disable');
         $title = ts('Disable "%1"?', [
-          1 => $this->_key,
+          1 => $this->label,
         ]);
         break;
     }
index 8ca42764d10854c3edaa1b6077042622538a68e7..40bf6e01c589ba57425fbb59bbb7417ef2647987 100644 (file)
@@ -35,9 +35,9 @@
         <td>
             {foreach from=$extension.requires item=ext}
                 {if array_key_exists($ext, $localExtensionRows)}
-                    {$localExtensionRows.$ext.name} (already downloaded - {$ext})
+                    {$localExtensionRows.$ext.label|escape} (already downloaded)
                 {elseif array_key_exists($ext, $remoteExtensionRows)}
-                    {$remoteExtensionRows.$ext.name} (not downloaded - {$ext})
+                    {$remoteExtensionRows.$ext.label|escape} (not downloaded)
                 {else}
                     {$ext} {ts}(not available){/ts}
                 {/if}
     <tr>
       <td class="label">{ts}Local path{/ts}</td><td>{$extension.path|escape}</td>
     </tr>
+    {if !empty($extension.downloadUrl)}
     <tr>
       <td class="label">{ts}Download location{/ts}</td><td>{$extension.downloadUrl|escape}</td>
     </tr>
-    <tr>
-      <td class="label">{ts}Key{/ts}</td><td>{$extension.key|escape}</td>
-    </tr>
+    {/if}
 </table>