pkgbase_details.php/pkg_details.php: Show keywords

Keywords are hyperlinked so a user can search for other packages with
the same name and/or keyword.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Marcel Korpel 2015-06-18 17:11:48 +02:00 committed by Lukas Fleischer
parent 6e3cbb9e65
commit d852da79e4
3 changed files with 44 additions and 2 deletions

View file

@ -53,6 +53,24 @@
text-align:right; text-align:right;
} }
.keyword:link, .keyword:visited {
float: left;
margin: 1px .5ex 1px 0;
padding: 0 1em;
color: white;
background-color: #36a;
border: 1px solid transparent;
border-radius: 2px;
}
.keyword:hover {
cursor: pointer;
}
.keyword:focus {
border: 1px dotted #000;
}
.text-button { .text-button {
background: transparent; background: transparent;
border: none !important; border: none !important;

View file

@ -190,11 +190,14 @@ $sources = pkg_sources($row["ID"]);
<td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td> <td><a href="<?= htmlspecialchars($row['URL'], ENT_QUOTES) ?>" title="<?= __('Visit the website for') . ' ' . htmlspecialchars( $row['Name'])?>"><?= htmlspecialchars($row['URL'], ENT_QUOTES) ?></a></td>
</tr> </tr>
<?php <?php
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))): if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"])) || count($keywords) > 0):
?> ?>
<tr> <tr>
<th><?= __('Keywords') . ': ' ?></th> <th><?= __('Keywords') . ': ' ?></th>
<td> <td>
<?php
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
?>
<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>"> <form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['BaseName']), ENT_QUOTES); ?>">
<div> <div>
<input type="hidden" name="action" value="do_SetKeywords" /> <input type="hidden" name="action" value="do_SetKeywords" />
@ -205,6 +208,15 @@ if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
<input type="submit" value="<?= __('Update') ?>"/> <input type="submit" value="<?= __('Update') ?>"/>
</div> </div>
</form> </form>
<?php
else:
foreach ($keywords as $kw) {
echo '<a class="keyword" href="';
echo get_uri('/packages/') . '?K=' . urlencode($kw) . '&amp;SB=p';
echo '">' . htmlspecialchars($kw) . "</a>\n";
}
endif;
?>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>

View file

@ -129,11 +129,14 @@ $pkgs = pkgbase_get_pkgnames($base_id);
</td> </td>
</tr> </tr>
<?php <?php
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))): if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"])) || count($keywords) > 0):
?> ?>
<tr> <tr>
<th><?= __('Keywords') . ': ' ?></th> <th><?= __('Keywords') . ': ' ?></th>
<td> <td>
<?php
if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
?>
<form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['Name']), ENT_QUOTES); ?>"> <form method="post" action="<?= htmlspecialchars(get_pkgbase_uri($row['Name']), ENT_QUOTES); ?>">
<div> <div>
<input type="hidden" name="action" value="do_SetKeywords" /> <input type="hidden" name="action" value="do_SetKeywords" />
@ -144,6 +147,15 @@ if (has_credential(CRED_PKGBASE_SET_KEYWORDS, array($row["MaintainerUID"]))):
<input type="submit" value="<?= __('Update') ?>"/> <input type="submit" value="<?= __('Update') ?>"/>
</div> </div>
</form> </form>
<?php
else:
foreach ($keywords as $kw) {
echo '<a class="keyword" href="';
echo get_uri('/packages/') . '?K=' . urlencode($kw) . '&amp;SB=p';
echo '">' . htmlspecialchars($kw) . "</a>\n";
}
endif;
?>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>