summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorMarcel Korpel <marcel.lists@gmail.com>2013-01-09 17:41:33 +0000
committerLukas Fleischer <archlinux@cryptocrack.de>2013-01-19 12:18:13 +0100
commit8e1051932eb86ef87f7b64efc86f50e633201b56 (patch)
treece7bd28a65411339ca5cb5f711ddb6b79a01fa98 /web/lib/pkgfuncs.inc.php
parentb004333eadb9a4db57592bb501b28edced708943 (diff)
downloadaurweb-8e1051932eb86ef87f7b64efc86f50e633201b56.tar.xz
Add description meta-element to package pages
Implements FS#33294 Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php81
1 files changed, 51 insertions, 30 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index c00c33d..568ca3d 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -432,17 +432,52 @@ function pkgname_is_blacklisted($name, $dbh=NULL) {
}
/**
+ * Get the package details
+ *
+ * @param string $id The package ID to get description for
+ * @param \PDO $dbh An already established database connection
+ *
+ * @return array The package's details OR error message
+ **/
+function get_package_details($id=0, $dbh=NULL) {
+ if(!$dbh) {
+ $dbh = db_connect();
+ }
+
+ $q = "SELECT Packages.*,Category ";
+ $q.= "FROM Packages,PackageCategories ";
+ $q.= "WHERE Packages.CategoryID = PackageCategories.ID ";
+ $q.= "AND Packages.ID = " . intval($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
* @global bool $USE_VIRTUAL_URLS True if using URL rewriting, otherwise false
* @param string $id The package ID to get details page for
+ * @param array $row Package details retrieved by get_package_details
* @param string $SID The session ID of the visitor
* @param \PDO $dbh An already established database connection
*
* @return void
*/
-function package_details($id=0, $SID="", $dbh=NULL) {
+function display_package_details($id=0, $row, $SID="", $dbh=NULL) {
global $AUR_LOCATION;
global $USE_VIRTUAL_URLS;
@@ -450,42 +485,28 @@ function package_details($id=0, $SID="", $dbh=NULL) {
$dbh = db_connect();
}
- $q = "SELECT Packages.*,Category ";
- $q.= "FROM Packages,PackageCategories ";
- $q.= "WHERE Packages.CategoryID = PackageCategories.ID ";
- $q.= "AND Packages.ID = " . intval($id);
- $result = $dbh->query($q);
-
- if (!$result) {
- print "<p>" . __("Error retrieving package details.") . "</p>\n";
+ if (isset($row['error'])) {
+ print "<p>" . $row['error'] . "</p>\n";
}
else {
- $row = $result->fetch(PDO::FETCH_ASSOC);
- if (empty($row)) {
- print "<p>" . __("Package details could not be found.") . "</p>\n";
+ include('pkg_details.php');
- }
- else {
- include('pkg_details.php');
-
- # Actions Bar
- if ($SID) {
- include('actions_form.php');
- if (isset($_REQUEST['comment']) && check_token()) {
- $uid = uid_from_sid($SID, $dbh);
- add_package_comment($id, $uid, $_REQUEST['comment'], $dbh);
- }
- include('pkg_comment_form.php');
+ # Actions Bar
+ if ($SID) {
+ include('actions_form.php');
+ if (isset($_REQUEST['comment']) && check_token()) {
+ $uid = uid_from_sid($SID, $dbh);
+ add_package_comment($id, $uid, $_REQUEST['comment'], $dbh);
}
+ include('pkg_comment_form.php');
+ }
- # Print Comments
- $comments = package_comments($id, $dbh);
- if (!empty($comments)) {
- include('pkg_comments.php');
- }
+ # Print Comments
+ $comments = package_comments($id, $dbh);
+ if (!empty($comments)) {
+ include('pkg_comments.php');
}
}
- return;
}