Improve results when searching for packages
authorMarcel Werk <burntime@woltlab.com>
Thu, 6 Aug 2020 15:42:47 +0000 (17:42 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 6 Aug 2020 15:42:47 +0000 (17:42 +0200)
Closes #3407

wcfsetup/install/files/acp/images/woltlabLogo-tiny.png [new file with mode: 0644]
wcfsetup/install/files/acp/style/layout.scss
wcfsetup/install/files/acp/templates/packageSearchResultList.tpl
wcfsetup/install/files/acp/templates/packageSearchResultListItems.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

diff --git a/wcfsetup/install/files/acp/images/woltlabLogo-tiny.png b/wcfsetup/install/files/acp/images/woltlabLogo-tiny.png
new file mode 100644 (file)
index 0000000..5321b6e
Binary files /dev/null and b/wcfsetup/install/files/acp/images/woltlabLogo-tiny.png differ
index 704b3e736889ab5d06c256cf8fa7e948b5f444de..81f83df537082d79a28a4f9f5dd010298f02218c 100644 (file)
@@ -466,6 +466,28 @@ $wcfAcpSubMenuWidth: 300px;
 }
 
 /* Search for Packages */
+.packageSearchResultRow {
+       .columnText {
+               padding: 15px 10px;
+       }
+       
+       td.columnIcon {
+               position: relative;
+               width: 44px;
+               
+               a {
+                       align-items: center;
+                       bottom: 5px;
+                       display: flex;
+                       justify-content: center;
+                       left: 0;
+                       position: absolute;
+                       right: 0;
+                       top: 5px;
+               }
+       }
+}
+
 .packageSearchName {
        @include wcfFontHeadline;
        @include wcfFontBold;
@@ -474,15 +496,32 @@ $wcfAcpSubMenuWidth: 300px;
 .packageSearchVersion {
        color: $wcfContentDimmedText;
        font-weight: 400;
-       padding-left: 5px;
+}
+
+.packageSearchDescription {
+       margin-top: 3px;
 }
 
 .packageSearchPackage {
        color: $wcfContentDimmedText;
        font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
-       font-weight: 400;
-       
-       @include wcfFontSmall;
+}
+
+.packageSearchAuthor,
+.packageSearchLicense {
+       white-space: nowrap;
+}
+
+.packageSearchAuthorWoltlab::before {
+       background-image: url(../images/woltlabLogo-tiny.png);
+       background-size: contain;
+       content: "";
+       display: inline-block;
+       height: 12px;
+       margin-right: 2px;
+       position: relative;
+       top: 1px;
+       width: 22px;
 }
 
 #packageSearchResultContainer {
index 1acc835d3df085f0e4c339bfd7ff7e9a566d2e1d..610cd845220db17c79d43c78838f3aedb26f02ea 100644 (file)
        </thead>
        
        <tbody>
-               <tr>
-                       <td colspan="5"><small>{lang count=$trustedSources|count}wcf.acp.package.search.result.trusted{/lang}</small></td>
-               </tr>
-               {foreach from=$trustedSources item=$package}
-                       <tr class="jsPackageRow">
-                               <td class="columnIcon">
-                                       <a href="#" class="jsInstallPackage" data-confirm-message="{lang __encode=true}wcf.acp.package.install.confirmMessage{/lang}" data-package="{$package->package}" data-package-version="{$package->getAccessibleVersion()->packageVersion}"><span class="icon icon16 fa-plus jsTooltip" title="{lang}wcf.acp.package.button.installPackage{/lang}"></span></a>
-                               </td>
-                               <td class="columnTitle" title="{$package->packageDescription}">
-                                       <div class="packageSearchName">{$package->packageName} <span class="packageSearchVersion">{$package->getAccessibleVersion()->packageVersion}</span></div>
-                                       <span class="packageSearchPackage">{$package->package}</span>
-                               </td>
-                               <td class="columnText">{if $package->authorURL}<a href="{$package->authorURL}" class="externalURL">{$package->author}</a>{else}{$package->author}{/if}</td>
-                               <td class="columnText">{if $package->getAccessibleVersion()->licenseURL}<a href="{$package->getAccessibleVersion()->licenseURL}" class="externalURL">{$package->getAccessibleVersion()->license}</a>{else}{$package->getAccessibleVersion()->license}{/if}</td>
-                               <td class="columnDate">{@$package->getAccessibleVersion()->packageDate|time}</td>
+               {if $officialPackages|count}
+                       <tr>
+                               <td colspan="5"><small>{lang count=$officialPackages|count}wcf.acp.package.search.result.official{/lang}</small></td>
+                       </tr>
+                       {include file='packageSearchResultListItems' packages=$officialPackages}
+               {/if}
+               {if $trustedSources|count}
+                       <tr>
+                               <td colspan="5"><small>{lang count=$trustedSources|count}wcf.acp.package.search.result.trusted{/lang}</small></td>
                        </tr>
-               {/foreach}
-               {hascontent}
+                       {include file='packageSearchResultListItems' packages=$trustedSources}
+               {/if}
+               {if $thirdPartySources|count}
                        <tr>
-                               <td colspan="5"><small>{lang count=$thirdPartySources|count}wcf.acp.package.search.result.thirdParty{/lang}</small></td>
+                               <td colspan="5"><small>{lang count=$thirdPartySources|count}wcf.acp.package.search.result.trusted{/lang}</small></td>
                        </tr>
-                       {content}
-                               {foreach from=$thirdPartySources item=$package}
-                                       <tr class="jsPackageRow">
-                                               <td class="columnIcon">
-                                                       <a href="#" class="jsInstallPackage" data-confirm-message="{lang __encode=true}wcf.acp.package.install.confirmMessage{/lang}" data-package="{$package->package}" data-package-version="{$package->getAccessibleVersion()->packageVersion}"><span class="icon icon16 fa-plus jsTooltip" title="{lang}wcf.acp.package.button.installPackage{/lang}"></span></a>
-                                               </td>
-                                               <td class="columnTitle" title="{$package->packageDescription}">
-                                                       <div class="packageSearchName">{$package->packageName} <span class="packageSearchVersion">{$package->getAccessibleVersion()->packageVersion}</span></div>
-                                                       <span class="packageSearchPackage">{$package->package}</span>
-                                               </td>
-                                               <td class="columnText">{if $package->authorURL}<a href="{$package->authorURL}" class="externalURL">{$package->author}</a>{else}{$package->author}{/if}</td>
-                                               <td class="columnText">{if $package->getAccessibleVersion()->licenseURL}<a href="{$package->getAccessibleVersion()->licenseURL}" class="externalURL">{$package->getAccessibleVersion()->license}</a>{else}{$package->getAccessibleVersion()->license}{/if}</td>
-                                               <td class="columnDate">{@$package->getAccessibleVersion()->packageDate|time}</td>
-                                       </tr>
-                               {/foreach}
-                       {/content}
-               {/hascontent}
+                       {include file='packageSearchResultListItems' packages=$thirdPartySources}
+               {/if}
        </tbody>
 </table>
diff --git a/wcfsetup/install/files/acp/templates/packageSearchResultListItems.tpl b/wcfsetup/install/files/acp/templates/packageSearchResultListItems.tpl
new file mode 100644 (file)
index 0000000..3059f48
--- /dev/null
@@ -0,0 +1,18 @@
+{foreach from=$packages item=$package}
+       <tr class="jsPackageRow packageSearchResultRow">
+               <td class="columnIcon">
+                       <a href="#" class="jsInstallPackage jsTooltip" data-confirm-message="{lang __encode=true}wcf.acp.package.install.confirmMessage{/lang}" data-package="{$package->package}" data-package-version="{$package->getAccessibleVersion()->packageVersion}" title="{lang}wcf.acp.package.button.installPackage{/lang}"><span class="icon icon24 fa-plus"></span></a>
+               </td>
+               <td class="columnText">
+                       <div class="packageSearchName">{$package->packageName} <span class="packageSearchVersion">{$package->getAccessibleVersion()->packageVersion}</span></div>
+                       <div class="packageSearchDescription small">{$package->packageDescription}</div>
+                       <span class="packageSearchPackage small">{$package->package}</span>
+                       {if $package->pluginStoreFileID}
+                               <span class="packageSearchPluginStorePage separatorLeft small"><a href="https://pluginstore.woltlab.com/file/{@$package->pluginStoreFileID}/" class="externalURL jsTooltip" title="{lang}wcf.acp.pluginStore.file.link{/lang}">{lang}wcf.acp.pluginStore.file{/lang}</a></span>
+                       {/if}
+               </td>
+               <td class="columnText small packageSearchAuthor{if $package->getUpdateServer()->isWoltLabUpdateServer()} packageSearchAuthorWoltlab{/if}" title="{$package->author}">{if $package->authorURL}<a href="{$package->authorURL}" class="externalURL">{$package->author|truncate:30}</a>{else}{$package->author|truncate:30}{/if}</td>
+               <td class="columnText small packageSearchLicense" title="{$package->getAccessibleVersion()->license}">{if $package->getAccessibleVersion()->licenseURL}<a href="{$package->getAccessibleVersion()->licenseURL}" class="externalURL">{$package->getAccessibleVersion()->license|truncate:30}</a>{else}{$package->getAccessibleVersion()->license|truncate:30}{/if}</td>
+               <td class="columnDate packageSearchDate">{@$package->getAccessibleVersion()->packageDate|time}</td>
+       </tr>
+{/foreach}
index 0e857fe7d299bb42658e1f71caf5aca907c3a58e..de7e6b7e14469ac23a8f3f7f8868ccf6b5d1e0d1 100644 (file)
@@ -66,6 +66,7 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                // there are no available package update servers
                if (empty($availableUpdateServers)) {
                        WCF::getTPL()->assign([
+                               'officialPackages' => [],
                                'thirdPartySources' => [],
                                'trustedSources' => [],
                        ]);
@@ -96,6 +97,7 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                // no matches found
                if (empty($packageUpdateIDs)) {
                        WCF::getTPL()->assign([
+                               'officialPackages' => [],
                                'thirdPartySources' => [],
                                'trustedSources' => [],
                        ]);
@@ -134,6 +136,7 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                // no matches found
                if (empty($packageUpdates)) {
                        WCF::getTPL()->assign([
+                               'officialPackages' => [],
                                'thirdPartySources' => [],
                                'trustedSources' => [],
                        ]);
@@ -459,10 +462,11 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                
                // assign versions
                /**
+                * @var ViewablePackageUpdate[] $officialPackages
                 * @var ViewablePackageUpdate[] $thirdPartySources
                 * @var ViewablePackageUpdate[] $trustedSources
                 */
-               $thirdPartySources = $trustedSources = [];
+               $officialPackages = $thirdPartySources = $trustedSources = [];
                /**
                 * @var int $packageUpdateID
                 * @var ViewablePackageUpdate $packageUpdate
@@ -473,7 +477,10 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                        $packageUpdate->setLatestVersion($updateVersions[$versionIDs['existing']]);
                        $packageUpdate->setUpdateServer($updateServers[$packageUpdate->packageUpdateServerID]);
                        
-                       if ($packageUpdate->getUpdateServer()->isTrustedServer() || $packageUpdate->getUpdateServer()->isWoltLabStoreServer()) {
+                       if ($packageUpdate->getUpdateServer()->isWoltLabUpdateServer()) {
+                               $officialPackages[] = $packageUpdate;
+                       }
+                       else if ($packageUpdate->getUpdateServer()->isTrustedServer() || $packageUpdate->getUpdateServer()->isWoltLabStoreServer()) {
                                $trustedSources[] = $packageUpdate;
                        }
                        else {
@@ -481,6 +488,9 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                        }
                }
                
+               uasort($officialPackages, function(ViewablePackageUpdate $a, ViewablePackageUpdate $b) {
+                       return strnatcasecmp($a->getName(), $b->getName());
+               });
                uasort($thirdPartySources, function(ViewablePackageUpdate $a, ViewablePackageUpdate $b) {
                        return strnatcasecmp($a->getName(), $b->getName());
                });
@@ -489,12 +499,13 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                });
                
                WCF::getTPL()->assign([
+                       'officialPackages' => $officialPackages,
                        'thirdPartySources' => $thirdPartySources,
                        'trustedSources' => $trustedSources,
                ]);
                
                return [
-                       'count' => count($thirdPartySources) + count($trustedSources),
+                       'count' => count($officialPackages) + count($thirdPartySources) + count($trustedSources),
                        'template' => WCF::getTPL()->fetch('packageSearchResultList'),
                ];
        }
index 4b5097edc97dfc0eeedcbbd686488123349e4163..70bb8616bfe5bc1ac00f3dfc269788a0720302bc 100644 (file)
@@ -1957,6 +1957,7 @@ Die Datenbestände werden sorgfältig gepflegt, aber es ist nicht ausgeschlossen
                <item name="wcf.acp.package.search.status.loading"><![CDATA[Suche läuft …]]></item>
                <item name="wcf.acp.package.search.status.noResults"><![CDATA[Die Suche ergab keine Treffer.]]></item>
                <item name="wcf.acp.package.search.status.refreshDatabase"><![CDATA[Die Paketlisten werden aktualisiert …]]></item>
+               <item name="wcf.acp.package.search.result.official"><![CDATA[{if $count === 0}Keine{elseif $count === 1}Ein{else}{#$count}{/if} Treffer in offiziellen WoltLab®-Paketen]]></item>
                <item name="wcf.acp.package.search.result.thirdParty"><![CDATA[{if $count === 0}Keine{elseif $count === 1}Ein{else}{#$count}{/if} Treffer in Paketquellen von Drittanbietern]]></item>
                <item name="wcf.acp.package.search.result.trusted"><![CDATA[{if $count === 0}Keine{elseif $count === 1}Ein{else}{#$count}{/if} Treffer in offiziellen Paketquellen]]></item>
                <item name="wcf.acp.package.error.databaseChange"><![CDATA[Das Datenbanklayout konnte aufgrund folgender Fehler nicht aktualisiert werden:
index d45d82840826adca593c6996227d3fe1be617cfc..d6681c93d78d0ce6700f5359f5faa411b5482b14 100644 (file)
@@ -1941,6 +1941,7 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
                <item name="wcf.acp.package.search.status.loading"><![CDATA[Searching…]]></item>
                <item name="wcf.acp.package.search.status.noResults"><![CDATA[There were no matches.]]></item>
                <item name="wcf.acp.package.search.status.refreshDatabase"><![CDATA[Retrieving the package lists…]]></item>
+               <item name="wcf.acp.package.search.result.official"><![CDATA[{if $count === 0}No matches{elseif $count === 1}One match{else}{#$count} matches{/if} in official WoltLab® packages]]></item>
                <item name="wcf.acp.package.search.result.thirdParty"><![CDATA[{if $count === 0}No matches{elseif $count === 1}One match{else}{#$count} matches{/if} in package sources maintained by third parties]]></item>
                <item name="wcf.acp.package.search.result.trusted"><![CDATA[{if $count === 0}No matches{elseif $count === 1}One match{else}{#$count} matches{/if} in official package sources]]></item>
                <item name="wcf.acp.package.error.databaseChange"><![CDATA[The database layout could not be changed because of the following errors: