packages.php 2.77 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2

3
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
pjmattal's avatar
pjmattal committed
4

5
6
7
8
include_once("aur.inc.php");      # access AUR common functions
set_lang();                       # this sets up the visitor's language
include_once('pkgfuncs.inc.php'); # package specific functions
check_sid();                      # see if they're still logged in
9

10
11
12
13
14
# Retrieve package ID and name, unless initialized by the routing framework
if (!isset($pkgid) || !isset($pkgname)) {
	if (isset($_GET['ID'])) {
		$pkgid = intval($_GET['ID']);
	} else if (isset($_GET['N'])) {
15
		$pkgid = pkg_from_name($_GET['N']);
16
	} else {
17
		unset($pkgid);
18
	}
19
}
20

21
22
23
$details = array();
if (isset($pkgid)) {
	$details = pkg_get_details($pkgid);
24
25
26
27
28
	if (isset($details['Name'])) {
		$pkgname = $details['Name'];
	} else {
		$pkgname = null;
	}
29
30
31
32
33
34
35
36
} else {
	unset($pkgname);
}

if (isset($pkgid) && ($pkgid == 0 || $pkgid == NULL || $pkgname == NULL)) {
	header("HTTP/1.0 404 Not Found");
	include "./404.php";
	return;
37
38
}

39
# Set the title to the current query or package name
40
if (isset($pkgname)) {
41
	$title = $pkgname;
42
43
} else if (!empty($_GET['K'])) {
	$title = __("Search Criteria") . ": " . $_GET['K'];
44
45
46
47
} else {
	$title = __("Packages");
}

48
html_header($title, $details);
49
?>
eric's avatar
eric committed
50

51
52
53
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
function collapseDependsList(list) {
54
55
56
57
58
59
60
61
62
63
64
	list = $(list);
	// Hide everything past a given limit. Don't do anything if we don't have
	// enough items, or the link already exists.
	var limit = 20,
		linkid = list.attr('id') + 'link',
		items = list.find('li').slice(limit);
	if (items.length <= 1 || $('#' + linkid).length > 0) {
		return;
	}
	items.hide();
	list.after('<p><a id="' + linkid + '" href="#">Show More…</a></p>');
65

66
67
68
69
70
71
72
	// add link and wire it up to show the hidden items
	$('#' + linkid).click(function(event) {
		event.preventDefault();
		list.find('li').show();
		// remove the full <p/> node from the DOM
		$(this).parent().remove();
	});
73
74
75
}

$(document).ready(function() {
76
77
78
	collapseDependsList("#pkgdepslist");
	collapseDependsList("#pkgreqslist");
	collapseDependsList("#pkgsrcslist");
79
80
81
});
</script>

Loui Chang's avatar
Loui Chang committed
82
<?php
83
84
include('pkg_search_form.php');

85
86
if (isset($pkgid)) {
	if ($pkgid) {
87
		if (isset($_COOKIE["AURSID"])) {
88
			pkg_display_details($pkgid, $details, $_COOKIE["AURSID"]);
89
90
		}
		else {
91
			pkg_display_details($pkgid, $details, null);
92
		}
93
94
	} else {
		print __("Error trying to retrieve package details.")."<br />\n";
95
	}
96
} else {
97
	if (!isset($_GET['K']) && !isset($_GET['SB'])) {
98
		$_GET['SB'] = 'p';
99
100
		$_GET['SO'] = 'd';
	}
101
	echo '<div id="pkglist-results" class="box">';
Dan McGee's avatar
Dan McGee committed
102
	if (isset($_COOKIE["AURSID"])) {
Lukas Fleischer's avatar
Lukas Fleischer committed
103
		pkg_search_page($_GET, true, $_COOKIE["AURSID"]);
Dan McGee's avatar
Dan McGee committed
104
	} else {
Lukas Fleischer's avatar
Lukas Fleischer committed
105
		pkg_search_page($_GET, true);
Dan McGee's avatar
Dan McGee committed
106
	}
107
	echo '</div>';
eric's avatar
eric committed
108
}
eric's avatar
eric committed
109

110
html_footer(AURWEB_VERSION);
111