From e5c0107d8c0dca4bdbbfa6fa26c2ef4d8997be6a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 18 Feb 2019 14:28:52 +0100 Subject: lib/style.php,packages/index.php: move displaying part of package listing to a separate function in a separate file --- lib/style.php | 96 ++++++++++++++++++++++++++++++++++++++++ packages/index.php | 125 ++++++++--------------------------------------------- 2 files changed, 113 insertions(+), 108 deletions(-) diff --git a/lib/style.php b/lib/style.php index 622e764..2fe2992 100644 --- a/lib/style.php +++ b/lib/style.php @@ -74,3 +74,99 @@ function print_footer() { \n"; + print " \n"; + print " \n"; + + foreach ($sorts as $get => $sort) { + print " \n"; + if ($print_order_links) { + print " " . $sort["label"] . "\n"; + } else + print " " . $sort["label"] . "\n"; + print " \n"; + } + + print " \n"; + print " \n"; + print " \n"; + $oddity = "odd"; + foreach ($list as $row) { + print " \n"; + print " \n"; + print " " . $row["arch"] . "\n"; + print " \n"; + 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"; + print " \n"; + print " "; + if (isset($row["move_date"])) + print $row["move_date"]; + else + print " "; + print "\n"; + print " \n"; + print " \n"; + print " "; + if ($row["is_to_be_deleted"]) + print "to be deleted"; + else + print " "; + print "\n"; + print " \n"; + print " \n"; + if ($oddity == "odd" ) + $oddity = "even"; + else + $oddity = "odd"; + } + print " \n"; + print " \n"; +} diff --git a/packages/index.php b/packages/index.php index e49540a..d38cffa 100644 --- a/packages/index.php +++ b/packages/index.php @@ -103,9 +103,19 @@ require_once BASE . "/lib/format.php"; $filter .= " AND " . $criterium["options"][$_GET[$criterium["name"]]]; if (isset($_GET["q"])) { + $extra_joins = ""; $exact_filter = " AND `binary_packages`.`pkgname` = from_base64(\"".base64_encode($_GET["q"])."\")"; $fuzzy_filter = " AND `binary_packages`.`pkgname` LIKE from_base64(\"".base64_encode("%".$_GET["q"]."%")."\")"; + } elseif (isset($_GET["g"]) && isset($_GET["ra"])) { + $extra_joins = + mysql_join_binary_packages_install_target_providers() . + mysql_join_install_target_providers_install_targets(); + $fuzzy_filter = + " AND `install_targets`.`name`=from_base64(\"" . base64_encode($_GET["g"]) . "\")" . + " AND `r_a`.`name`=from_base64(\"" . base64_encode($_GET["ra"]) . "\")"; + $exact_filter = " AND 0"; } else { + $extra_joins = ""; $exact_filter = " AND 0"; $fuzzy_filter = ""; } @@ -118,13 +128,14 @@ require_once BASE . "/lib/format.php"; mysql_join_repositories_architectures("","r_a") . mysql_join_binary_packages_build_assignments() . mysql_join_build_assignments_package_sources() . + $extra_joins . $filter . $exact_filter . " ORDER BY "; $query .= "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`"; $result = mysql_run_query( - "SELECT " . + "SELECT DISTINCT " . "`binary_packages`.`pkgname`," . "`package_sources`.`pkgbase`," . "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`) AS `repo`," . @@ -195,6 +206,7 @@ require_once BASE . "/lib/format.php"; mysql_join_repositories_architectures("","r_a") . mysql_join_binary_packages_build_assignments() . mysql_join_build_assignments_package_sources() . + $extra_joins . $filter . $fuzzy_filter . " ORDER BY "; @@ -208,7 +220,7 @@ require_once BASE . "/lib/format.php"; $query .= "`binary_packages`.`pkgname`,`repositories`.`stability`,`repositories`.`name`,`architectures`.`name`"; $result = mysql_run_query( - "SELECT COUNT(1)" . $query + "SELECT COUNT(DISTINCT `binary_packages`.`id`)" . $query ); $num_results = implode($result -> fetch_assoc()); @@ -219,7 +231,7 @@ require_once BASE . "/lib/format.php"; $page = 1; $result = mysql_run_query( - "SELECT " . + "SELECT DISTINCT " . "`binary_packages`.`pkgname`," . "`package_sources`.`pkgbase`," . "CONCAT(`r_a`.`name`,\"/\",`repositories`.`name`) AS `repo`," . @@ -240,63 +252,6 @@ require_once BASE . "/lib/format.php"; $fuzzy_matches[] = $row; } - function print_results($results) { - $oddity="odd"; - foreach ($results as $row) { - print " \n"; - print " \n"; - print " " . $row["arch"] . "\n"; - print " \n"; - 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"; - print " \n"; - print " "; - if (isset($row["move_date"])) - print $row["move_date"]; - else - print " "; - print "\n"; - print " \n"; - print " \n"; - print " "; - if ($row["is_to_be_deleted"]) - print "to be deleted"; - else - print " "; - print "\n"; - print " \n"; - print " \n"; - if ($oddity == "odd" ) - $oddity = "even"; - else - $oddity = "odd"; - } - } - function header_and_footer() { global $page, $pages, $num_results; @@ -450,25 +405,9 @@ if (count($exact_matches) > 0) {

exact match found.

- - - - $sort) { - print " \n"; - } -?> - - - - -
\n"; - print " ".$sort["label"]."\n"; - print "
0) { header_and_footer(); -?> - - - - $sort) { - print " \n"; - } -?> - - - - - -
\n"; - print " ".$sort["label"]."\n"; - print "
-