diff options
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 84 | ||||
-rw-r--r-- | web/lib/routing.inc.php | 16 |
2 files changed, 99 insertions, 1 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 3ef069c..b92eb9c 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -445,6 +445,41 @@ function get_package_details($id=0) { } /** + * Get the package base details + * + * @param string $id The package base ID to get description for + * + * @return array The package base's details OR error message + **/ +function get_pkgbase_details($base_id) { + $dbh = DB::connect(); + + $q = "SELECT PackageBases.ID, PackageBases.Name, "; + $q.= "PackageBases.CategoryID, PackageBases.NumVotes, "; + $q.= "PackageBases.OutOfDateTS, PackageBases.SubmittedTS, "; + $q.= "PackageBases.ModifiedTS, PackageBases.SubmitterUID, "; + $q.= "PackageBases.MaintainerUID, PackageCategories.Category "; + $q.= "FROM PackageBases, PackageCategories "; + $q.= "WHERE PackageBases.CategoryID = PackageCategories.ID "; + $q.= "AND PackageBases.ID = " . intval($base_id); + $result = $dbh->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 * * @global string $AUR_LOCATION The AUR's URL used for notification e-mails @@ -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 "<p>" . $row['error'] . "</p>\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 @@ -816,6 +886,20 @@ function pkgbase_name_from_id($base_id) { } /** + * 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 * * @param int $base_id The ID of the 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() { |