From 0e19ad38c281378962ba6e7af9f6feef1ce70750 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 19 Feb 2019 11:03:46 +0100 Subject: lib/style.php: print_listing(): what to print in columns is now stored in an array, too --- lib/style.php | 169 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 116 insertions(+), 53 deletions(-) (limited to 'lib') 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( + '"', + '$name', + '"' + ), + '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( + '"', + '$pkgname', + '"' + ), + 'version' => array('$version'), + 'has_issues' => array( + 'has_issues' => array( + 0 => '" ', + 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 => '" ', + 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 " \n"; - print " \n"; - print " " . $row["arch"] . "\n"; - print " \n"; - if ($list_content_type == 'package') { - print " \n"; - print " " . $row["repo"] . "\n"; - print " \n"; - print " \n"; - print " " . $row["pkgname"] . "\n"; - print " \n"; - print " \n"; - print " " . $row["version"] . "\n"; - print " \n"; - print " \n"; - print " "; - if ($row["has_issues"]) - print "has open bug reports"; - else - print " "; - print "\n"; - print " \n"; - print " \n"; - print " "; - if (isset($row["build_date"])) - print $row["build_date"]; - else - print " "; - print "\n"; - print " \n"; - } - if ($list_content_type == 'group') { - print " \n"; - print " " . $row["name"] . "\n"; - print " \n"; - print " \n"; - print " " . $row["count"] . "\n"; - print " \n"; - } - print " \n"; - print " "; - if (isset($row["move_date"])) - print $row["move_date"]; - else - print " "; - print "\n"; - print " \n"; - if ($list_content_type == 'package') { + foreach ($print_columns as $print_column) { print " \n"; print " "; - if ($row["is_to_be_deleted"]) - print "to be deleted"; - else - print " "; + 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 ' '; + 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 " \n"; } -- cgit v1.2.3-70-g09d2