From f7d13b5b368f1432b9a1eb1798f94a70b9dc03b7 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 5 Apr 2014 02:06:54 +0200 Subject: Add package base detail pages This adds package base details pages, similar to the package details pages. Each package base details page contains general information (package base name, category, submitter, maintainer, ...) and links to all the corresponding packages. As on the package details pages, comments and links to several package actions are also provided. Signed-off-by: Lukas Fleischer --- web/html/index.php | 16 +++ web/html/pkgbase.php | 55 ++++++++++ web/lib/pkgfuncs.inc.php | 84 ++++++++++++++++ web/lib/routing.inc.php | 16 ++- web/template/pkgbase_details.php | 210 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 web/html/pkgbase.php create mode 100644 web/template/pkgbase_details.php (limited to 'web') diff --git a/web/html/index.php b/web/html/index.php index 542d594..e79955e 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -69,6 +69,22 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { } } + include get_route('/' . $tokens[1]); +} elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgbase_route()) { + if (!empty($tokens[2])) { + /* TODO: Create a proper data structure to pass variables from + * the routing framework to the individual pages instead of + * initializing arbitrary variables here. */ + $pkgbase_name = $tokens[2]; + $base_id = pkgbase_from_name($pkgbase_name); + + if (!$base_id) { + header("HTTP/1.0 404 Not Found"); + include "./404.php"; + return; + } + } + include get_route('/' . $tokens[1]); } elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_user_route()) { if (!empty($tokens[2])) { diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php new file mode 100644 index 0000000..e0c9af6 --- /dev/null +++ b/web/html/pkgbase.php @@ -0,0 +1,55 @@ + + +query($q); + + $row = array(); + + if (!$result) { + $row['error'] = __("Error retrieving package details."); + } + else { + $row = $result->fetch(PDO::FETCH_ASSOC); + if (empty($row)) { + $row['error'] = __("Package details could not be found."); + } + } + + return $row; +} + /** * Display the package details page * @@ -480,6 +515,41 @@ function display_package_details($id=0, $row, $SID="") { } } +/** + * Display the package base details page + * + * @global string $AUR_LOCATION The AUR's URL used for notification e-mails + * @global bool $USE_VIRTUAL_URLS True if using URL rewriting, otherwise false + * @param string $id The package base ID to get details page for + * @param array $row Package base details retrieved by get_pkgbase_details + * @param string $SID The session ID of the visitor + * + * @return void + */ +function display_pkgbase_details($base_id, $row, $SID="") { + global $AUR_LOCATION; + global $USE_VIRTUAL_URLS; + + $dbh = DB::connect(); + + if (isset($row['error'])) { + print "

" . $row['error'] . "

\n"; + } + else { + include('pkgbase_details.php'); + + if ($SID) { + include('actions_form.php'); + include('pkg_comment_form.php'); + } + + $comments = package_comments($base_id); + if (!empty($comments)) { + include('pkg_comments.php'); + } + } +} + /* pkg_search_page(SID) * outputs the body of search/search results page @@ -815,6 +885,20 @@ function pkgbase_name_from_id($base_id) { return $result->fetch(PDO::FETCH_COLUMN, 0); } +/** + * Get the names of all packages belonging to a package base + * + * @param int $base_id The ID of the package base + * + * @return array The names of all packages belonging to the package base + */ +function pkgbase_get_pkgnames($base_id) { + $dbh = DB::connect(); + $q = "SELECT Name FROM Packages WHERE PackageBaseID = " . intval($base_id); + $result = $dbh->query($q); + return $result->fetchAll(PDO::FETCH_COLUMN, 0); +} + /** * Delete all packages belonging to a package base * diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index b1e5be2..1b2aa52 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -4,6 +4,7 @@ $ROUTES = array( '' => 'home.php', '/index.php' => 'home.php', '/packages' => 'packages.php', + '/pkgbase' => 'pkgbase.php', '/register' => 'account.php', '/account' => 'account.php', '/accounts' => 'account.php', @@ -18,6 +19,7 @@ $ROUTES = array( ); $PKG_PATH = '/packages'; +$PKGBASE_PATH = '/pkgbase'; $USER_PATH = '/account'; function get_route($path) { @@ -47,6 +49,11 @@ function get_pkg_route() { return $PKG_PATH; } +function get_pkgbase_route() { + global $PKGBASE_PATH; + return $PKGBASE_PATH; +} + function get_pkg_uri($pkgname) { global $USE_VIRTUAL_URLS; global $PKG_PATH; @@ -59,7 +66,14 @@ function get_pkg_uri($pkgname) { } function get_pkgbase_uri($pkgbase_name) { - return get_pkg_uri($pkgbase_name); + global $USE_VIRTUAL_URLS; + global $PKGBASE_PATH; + + if ($USE_VIRTUAL_URLS) { + return $PKGBASE_PATH . '/' . urlencode($pkgbase_name) . '/'; + } else { + return '/' . get_route($PKGBASE_PATH) . '?N=' . urlencode($pkgbase_name); + } } function get_user_route() { diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php new file mode 100644 index 0000000..a77ecd3 --- /dev/null +++ b/web/template/pkgbase_details.php @@ -0,0 +1,210 @@ + +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + +
+
+ +
+ + +
+ +
+
+

+ 0): ?> +
    + +
  • + +
+ +
+
+
-- cgit v1.2.3-70-g09d2