Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/style.php
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-02-19 11:03:46 +0100
committerErich Eckner <git@eckner.net>2019-02-19 11:03:46 +0100
commit0e19ad38c281378962ba6e7af9f6feef1ce70750 (patch)
tree917b6bd67818e91e0e45bc1bd4ac6fdfddebddb9 /lib/style.php
parentdbbe9efceecb646acf5ee9d4565a8ab69e7d879b (diff)
lib/style.php: print_listing(): what to print in columns is now stored in an array, too
Diffstat (limited to 'lib/style.php')
-rw-r--r--lib/style.php169
1 files changed, 116 insertions, 53 deletions
diff --git a/lib/style.php b/lib/style.php
index 5bec6c2..ee40d10 100644
--- a/lib/style.php
+++ b/lib/style.php
@@ -82,6 +82,44 @@ function print_footer() {
* *
**********************************************************************/
+$difflist_sorts = array(
+ "name" => array(
+ "title" => "name",
+ "label" => "Name",
+ "mysql" => "`binary_packages`.`name`"
+ ),
+ "i486_version" => array(
+ "title" => "i486 version",
+ "label" => "i486 Version",
+ "mysql" => "`i486_version`"
+ ),
+ "i686_version" => array(
+ "title" => "i686 version",
+ "label" => "i686 Version",
+ "mysql" => "`i686_version`"
+ ),
+ "i486_repo" => array(
+ "title" => "i486 repository",
+ "label" => "i486 Repository",
+ "mysql" => "`i486_repo`"
+ ),
+ "i686_repo" => array(
+ "title" => "i686 repository",
+ "label" => "i686 Repository",
+ "mysql" => "`i686_repo`"
+ ),
+ "i486_last_moved" => array(
+ "title" => "i486 last updated",
+ "label" => "i486 Last Updated",
+ "mysql" => "`i486_last_moved`"
+ ),
+ "i686_last_moved" => array(
+ "title" => "i686 last updated",
+ "label" => "i686 Last Updated",
+ "mysql" => "`i686_last_moved`"
+ )
+);
+
$grouplist_sorts = array(
"arch" => array(
"title" => "architecture",
@@ -105,6 +143,22 @@ $grouplist_sorts = array(
)
);
+$grouplist_print_columns = array(
+ 'arch' => array('$arch'),
+ 'group' => array(
+ '"<a href="/groups/',
+ '$arch',
+ '"/',
+ '$name',
+ '"/" title="Group details for ',
+ '$name',
+ '"">',
+ '$name',
+ '"</a>'
+ ),
+ 'move_date' => array('&move_date')
+);
+
$pkglist_sorts = array(
"arch" => array(
"title" => "architecture",
@@ -148,6 +202,37 @@ $pkglist_sorts = array(
)
);
+$pkglist_print_columns = array(
+ 'arch' => array('$arch'),
+ 'repo' => array('$repo'),
+ 'pkgname' => array(
+ '"<a href="/packages/',
+ '$repo',
+ '"/',
+ '$pkgname',
+ '"/" title="View package details for ',
+ '$pkgname',
+ '"">',
+ '$pkgname',
+ '"</a>'
+ ),
+ 'version' => array('$version'),
+ 'has_issues' => array(
+ 'has_issues' => array(
+ 0 => '"&nbsp',
+ 1 => '"has open bug reports'
+ )
+ ),
+ 'build_date' => array('&build_date'),
+ 'move_date' => array('&move_date'),
+ 'is_to_be_deleted' => array(
+ 'is_to_be_deleted' => array(
+ 0 => '"&nbsp;',
+ 1 => '"to be deleted'
+ )
+ )
+);
+
function query_package_listing($filter, $limit, $float_columns, $count_only, $extract_order_by_from_get) {
global $pkglist_sorts;
@@ -217,14 +302,25 @@ function query_package_listing($filter, $limit, $float_columns, $count_only, $ex
function print_listing($list, $print_order_links, $list_content_type) {
+ global $difflist_sorts;
global $pkglist_sorts;
global $grouplist_sorts;
+ global $difflist_print_columns;
+ global $pkglist_print_columns;
+ global $grouplist_print_columns;
+
switch ($list_content_type) {
+ case 'diff':
+ $columns = $difflist_sorts;
+ $print_columns = $difflist_print_columns;
+ break;
case 'package':
$columns = $pkglist_sorts;
+ $print_columns = $pkglist_print_columns;
break;
case 'group':
$columns = $grouplist_sorts;
+ $print_columns = $grouplist_print_columns;
break;
default:
throw_http_error(500,'Internal Server Error','invalit list type "' . $list_content_type . '"' . "\n");
@@ -261,61 +357,28 @@ function print_listing($list, $print_order_links, $list_content_type) {
$oddity = "odd";
foreach ($list as $row) {
print " <tr class=\"" . $oddity . "\">\n";
- print " <td>\n";
- print " " . $row["arch"] . "\n";
- print " </td>\n";
- if ($list_content_type == 'package') {
- print " <td>\n";
- print " " . $row["repo"] . "\n";
- print " </td>\n";
- print " <td>\n";
- print " <a href=\"/packages/" . $row["repo"] . "/" . $row["pkgname"] ."/\" ";
- print "title=\"View package details for " . $row["pkgname"] . "\">" . $row["pkgname"] . "</a>\n";
- print " </td>\n";
- print " <td>\n";
- print " " . $row["version"] . "\n";
- print " </td>\n";
- print " <td>\n";
- print " ";
- if ($row["has_issues"])
- print "has open bug reports";
- else
- print "&nbsp;";
- print "\n";
- print " </td>\n";
- print " <td>\n";
- print " ";
- if (isset($row["build_date"]))
- print $row["build_date"];
- else
- print "&nbsp;";
- print "\n";
- print " </td>\n";
- }
- if ($list_content_type == 'group') {
- print " <td>\n";
- print " <a href=\"/groups/" . $row["arch"] . "/" . $row["name"] . "/\"";
- print " title=\"Group details for " . $row["name"] . "\">" . $row["name"] . "</a>\n";
- print " </td>\n";
- print " <td>\n";
- print " " . $row["count"] . "\n";
- print " </td>\n";
- }
- print " <td>\n";
- print " ";
- if (isset($row["move_date"]))
- print $row["move_date"];
- else
- print "&nbsp;";
- print "\n";
- print " </td>\n";
- if ($list_content_type == 'package') {
+ foreach ($print_columns as $print_column) {
print " <td>\n";
print " ";
- if ($row["is_to_be_deleted"])
- print "to be deleted";
- else
- print "&nbsp;";
+ foreach ($print_column as $part_key => $part_val) {
+ if (is_array($part_val))
+ $part_val = $part_val[$row[$part_key]];
+ switch (substr($part_val, 0, 1)) {
+ case '&':
+ if (empty($row[substr($part_val, 1)])) {
+ print '&nbsp;';
+ break;
+ }
+ case '$':
+ print $row[substr($part_val, 1)];
+ break;
+ case '"':
+ print substr($part_val, 1);
+ break;
+ default:
+ throw_http_error(500, 'Internal Server Error', 'Unknown variable type "' . substr($part_val, 0, 1) . '"');
+ }
+ }
print "\n";
print " </td>\n";
}