Skip to content

Commit 703abfd

Browse files
committed
Prettify the download page
1 parent 766bf21 commit 703abfd

File tree

5 files changed

+96
-219
lines changed

5 files changed

+96
-219
lines changed

include/get-download.inc

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
// $Id$
3-
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/mirrortable.inc';
43

54
// Try to make this page non-cached
65
header_nocache();
@@ -13,6 +12,11 @@ if (!isset($df)) {
1312
// Could be a normal download or a manual download file
1413
$possible_files = array($df, "manual/$df");
1514

15+
$site_config = array(
16+
'current' => 'downloads',
17+
'css' => array('mirror.css')
18+
);
19+
1620
// Find out what is the exact file requested
1721
$file = FALSE;
1822
foreach ($possible_files as $name) {
@@ -24,7 +28,7 @@ foreach ($possible_files as $name) {
2428

2529
// No downloadable file found
2630
if ($file === FALSE) {
27-
site_header("Download not found");
31+
site_header("Download not found", $site_config);
2832

2933
$info = "<p>
3034
The file you requested (<strong> " . htmlspecialchars($df, ENT_QUOTES, "UTF-8") . " </strong>) is not found on
@@ -47,36 +51,30 @@ EOT;
4751
$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file;
4852

4953
// Print out common header
50-
site_header('Get Download');
54+
site_header('Get Download', $site_config);
5155
?>
5256

57+
<div id="mirrors-container">
5358
<h1>Choose mirror site for download</h1>
5459

5560
<p>
5661
You have chosen to download the following file:
62+
<strong class="filename"><?php echo $df ?></strong><br />
5763
</p>
5864

59-
<div class="center">
60-
<table border="0" cellpadding="10" cellspacing="1" width="500">
61-
<tr bgcolor="#cccccc"><td align="center">
62-
<?php
63-
echo '<strong>' . $df . '</strong><br />';
64-
65+
<?php
6566
// Try to get filesize to display
6667
$size = @filesize($local_file);
6768
if ($size) {
6869
echo '<small>' . number_format($size, 0, '.', ',') . ' bytes</small><br />';
6970
}
7071
?>
71-
</td></tr></table>
72+
73+
<div class="mirrors-list">
74+
<?php print_full_mirror_list($df); ?>
75+
</div>
7276
</div>
7377

74-
<p>
75-
Please choose the mirror closest to you from which to download the file.
76-
The current mirror is highlighted in yellow, mirror sites detected to be
77-
out of date or dysfunctional are not listed for your convenience.
78-
</p>
79-
80-
<?php
81-
mirror_list($df);
82-
site_footer();
78+
79+
<?php site_footer();
80+

include/mirrortable.inc

-146
This file was deleted.

include/site.inc

+66
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,72 @@ function mirror_setcookie($name, $content, $exptime)
189189
}
190190
}
191191

192+
function organise_mirrors($mirrors) {
193+
// Lets group the mirrors by country code, for easy output on the page.
194+
$retval = array();
195+
foreach($mirrors as $key => $mirror) {
196+
197+
// If the mirror is not all right or it is virtual (not an official mirror), skip it
198+
if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; }
199+
200+
if(!isset($grouped_mirrors[$mirror[0]])) {
201+
$grouped_mirrors[$mirror[0]] = array();
202+
}
203+
204+
$retval[$mirror[0]][] = array(
205+
'url' => $key,
206+
'country_code' => $mirror[0],
207+
'provider_title' => $mirror[1],
208+
'provider_url' => $mirror[3]
209+
);
210+
211+
}
212+
return $retval;
213+
}
214+
function print_full_mirror_list($download_file = null) {
215+
global $COUNTRIES, $COUNTRY, $MIRRORS;
216+
217+
$groupped = organise_mirrors($MIRRORS);
218+
$close = count_mirrors($COUNTRY);
219+
if ($close) {
220+
$mnum = (($close > 1) ? "mirrors" : "mirror");
221+
echo "<p>We have automatically detected the following $mnum to be close to you</p>";
222+
223+
if (isset($groupped[$COUNTRY])) {
224+
print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $groupped[$COUNTRY], $download_file, true);
225+
echo "<br />";
226+
}
227+
}
228+
foreach($groupped as $mirrorcode => $country) {
229+
print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country, $download_file, false);
230+
}
231+
}
232+
233+
function print_mirror_box($countryname, $countrycode, $mirrors, $file = null, $homecountry = false) {
234+
?>
235+
<div class="mirror <?php echo $homecountry ? "homecountry" : ""?>">
236+
<div class="title"><?php echo $countryname; ?>
237+
<img alt="<?php echo $countrycode; ?>"
238+
height="25"
239+
width="45"
240+
src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>">
241+
</div>
242+
<?php foreach($mirrors as $mirror): ?>
243+
<?php
244+
$url = substr($mirror["url"], strpos($mirror["url"], '//') + 2, -1);
245+
if ($file) {
246+
$url = "/get/$file/from/$url/mirror";
247+
}
248+
?>
249+
<div class="entry">
250+
<div class="url"><a href="<?php echo $url; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div>
251+
<div class="provider"><a href="<?php echo $mirror['provider_url']; ?>" title="<?php echo clean($mirror['provider_title']); ?>"><?php echo clean($mirror['provider_title']); ?></a></div>
252+
</div>
253+
<?php endforeach; ?>
254+
</div>
255+
<?php
256+
}
257+
192258
// Use this function to write out proper headers on
193259
// pages where the content should not be publicly cached
194260
function header_nocache()

mirrors.php

+1-53
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,7 @@
1010
);
1111
site_header("Mirror Sites", $header_config);
1212

13-
function print_mirror_box($countryname, $countrycode, $country, $homecountry = false) {
14-
?>
15-
<div class="mirror <?php echo $homecountry ? "homecountry" : ""?>">
16-
<div class="title"><?php echo $countryname; ?>
17-
<img alt="<?php echo $countrycode; ?>"
18-
height="25"
19-
width="45"
20-
src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>">
21-
</div>
22-
<?php foreach($country as $mirror): ?>
23-
<div class="entry">
24-
<div class="url"><a href="<?php echo $mirror['url']; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div>
25-
<div class="provider"><a href="<?php echo $mirror['provider_url']; ?>" title="<?php echo clean($mirror['provider_title']); ?>"><?php echo clean($mirror['provider_title']); ?></a></div>
26-
</div>
27-
<?php endforeach; ?>
28-
</div>
29-
<?php
30-
}
31-
32-
// Lets group the mirrors by country code, for easy output on the page.
33-
$grouped_mirrors = array();
34-
foreach($MIRRORS as $key => $mirror) {
35-
36-
// If the mirror is not all right or it is virtual (not an official mirror), skip it
37-
if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; }
38-
39-
if(!isset($grouped_mirrors[$mirror[0]])) {
40-
$grouped_mirrors[$mirror[0]] = array();
41-
}
4213

43-
$grouped_mirrors[$mirror[0]][] = array(
44-
'url' => $key,
45-
'country_code' => $mirror[0],
46-
'provider_title' => $mirror[1],
47-
'provider_url' => $mirror[3]
48-
);
49-
}
50-
51-
$close = count_mirrors($COUNTRY);
5214
?>
5315
<div id="mirrors-container">
5416

@@ -74,21 +36,7 @@ function print_mirror_box($countryname, $countrycode, $country, $homecountry = f
7436
</div>
7537

7638
<div class="mirrors-list">
77-
<?php if ($close) {
78-
$mnum = (($close > 1) ? "mirrors" : "mirror");
79-
echo "<p>We have automatically detected the following $mnum to be close to you</p>";
80-
81-
if (isset($grouped_mirrors[$COUNTRY])) {
82-
print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $grouped_mirrors[$COUNTRY], 1);
83-
echo "<br />";
84-
}
85-
}
86-
?>
87-
88-
<?php foreach($grouped_mirrors as $mirrorcode => $country): ?>
89-
<?php print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country) ?>
90-
<?php endforeach ?>
91-
39+
<?php print_full_mirror_list() ?>
9240
</div>
9341

9442
</div>

styles/mirror.css

+12-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ div#usernotes a.usernotes-voted:hover {
4545
font-size: 1.7em;
4646
}
4747

48+
#mirrors-container .filename {
49+
display: block;
50+
padding: 20px;
51+
border: 1px;
52+
font-size: 1.4em;
53+
background-color: #EEE;
54+
text-align: center;
55+
}
56+
4857

4958
#mirrors-container .mirrors-list .mirror {
5059
display: inline-block;
@@ -59,10 +68,12 @@ div#usernotes a.usernotes-voted:hover {
5968
display: block;
6069
margin: 5px auto;
6170
height: 100%;
71+
background-color: #9C9;
72+
padding: 20px 20px 40px 20px;
6273
}
6374

6475
#mirrors-container .mirrors-list .mirror:hover {
65-
background-color: #EEE;
76+
background-color: #9C9;
6677
}
6778

6879
#mirrors-container .mirrors-list .mirror .url {

0 commit comments

Comments
 (0)