Add helper methods to LicenseData
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:16:08 +0000 (15:16 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 27 Sep 2023 13:36:15 +0000 (15:36 +0200)
wcfsetup/install/files/acp/templates/license.tpl
wcfsetup/install/files/lib/acp/page/LicensePage.class.php
wcfsetup/install/files/lib/system/package/license/LicenseData.class.php

index a1f1306596adf4a260104a029cf315ead4c32b50..0f1b81b98aab66c9592aba1d1ec6cae1949448be 100644 (file)
@@ -34,8 +34,8 @@
 <header class="contentHeader">
     <div class="contentHeaderTitle">
         <h1 class="contentTitle">{lang}wcf.acp.license{/lang}</span></h1>
-        {if $licenseNumber}
-            <p class="contentDescription">{lang}wcf.acp.license.licenseNo{/lang}</p>
+        {if $licenseData->getLicenseNumber()}
+            <p class="contentDescription">{lang licenseNumber=$licenseData->getLicenseNumber()}wcf.acp.license.licenseNo{/lang}</p>
         {/if}
     </div>
 
@@ -59,7 +59,7 @@
     {/hascontent}
 </header>
 
-{if $licenseData->license[type] === 'developer'}
+{if $licenseData->getLicenseType() === 'developer'}
     <p class="warning">{lang}wcf.acp.license.developerLicense{/lang}</p>
 {/if}
 
                                                 {lang accessibleVersion=$requiresLicenseExtension[$package]}wcf.acp.license.package.outdated{/lang}
                                             </span>
                                         {/if}
-                                        <a href="https://www.woltlab.com/license-extend/{$licenseNumber}/" class="externalURL" rel="nofollow noopener" target="_blank">{lang}wcf.acp.license.extend{/lang}</a>
+                                        <a href="https://www.woltlab.com/license-extend/{$licenseData->getLicenseNumber()}/" class="externalURL" rel="nofollow noopener" target="_blank">{lang}wcf.acp.license.extend{/lang}</a>
                                     </span>
                                 {else}
                                     <button type="button" class="button small jsInstallPackage" data-package="{$package}" data-package-version="{$installablePackages[$package]}">
index baec0f028a6cece319e90bd1ff01fa07e3403f65..c72f1b702493faf507e039e6136401acc7f7eb2d 100644 (file)
@@ -33,8 +33,6 @@ final class LicensePage extends AbstractPage
 
     private array $availablePackages = [];
 
-    private int $licenseNumber;
-
     private array $installedPackages;
 
     private array $installablePackages = [];
@@ -66,9 +64,6 @@ final class LicensePage extends AbstractPage
         $licenseApi->updateLicenseFile();
 
         $this->licenseData = $licenseApi->getData();
-        if (isset($this->licenseData->license['licenseID'])) {
-            $this->licenseNumber = $this->licenseData->license['licenseID'];
-        }
 
         $identifiers = \array_merge(
             \array_keys($this->licenseData->woltlab),
@@ -128,7 +123,6 @@ final class LicensePage extends AbstractPage
         WCF::getTPL()->assign([
             'licenseData' => $this->licenseData,
             'availablePackages' => $this->availablePackages,
-            'licenseNumber' => $this->licenseNumber,
             'installedPackages' => $this->installedPackages,
             'installablePackages' => $this->installablePackages,
             'packageUpdates' => $this->packageUpdates,
index bfdc351f9bd0698b5080add055ffb41b6658c9e6..827feb1b59510869744c7a3f60a43c72a887db29 100644 (file)
@@ -30,4 +30,14 @@ final class LicenseData
     )
     {
     }
+
+    public function getLicenseNumber(): ?string
+    {
+        return $this->license['licenseID'] ?? null;
+    }
+
+    public function getLicenseType(): string
+    {
+        return $this->license['type'];
+    }
 }