com web/php: Prettify the download page: include/get-download.inc include/mirrortable.inc include/site.inc mirrors.php styles/mirror.css
| From: | Hannes Magnusson | Date: | Wed, 20 Nov 2013 22:04:58 +0000 |
| Subject: | com web/php: Prettify the download page: include/get-download.inc include/mirrortable.inc include/site.inc mirrors.php styles/mirror.css | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-17086@lists.php.net to get a copy of this message | ||
Commit: 703abfd16b79743ee33baa155757d0ee49caf8c0
Author: Hannes Magnusson <bjori@mongodb.com> Wed, 20 Nov 2013 14:04:33 -0800
Parents: 766bf21ed7d77d237adfb1694588c2996ac9ebc0
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=703abfd16b79743ee33baa155757d0ee49caf8c0
Log:
Prettify the download page
Changed paths:
M include/get-download.inc
D include/mirrortable.inc
M include/site.inc
M mirrors.php
M styles/mirror.css
diff --git a/include/get-download.inc b/include/get-download.inc index d1ca357..f46d73e 100644 --- a/include/get-download.inc +++ b/include/get-download.inc @@ -1,6 +1,5 @@ <?php // $Id$ -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/mirrortable.inc'; // Try to make this page non-cached header_nocache(); @@ -13,6 +12,11 @@ if (!isset($df)) { // Could be a normal download or a manual download file $possible_files = array($df, "manual/$df"); +$site_config = array( + 'current' => 'downloads', + 'css' => array('mirror.css') +); + // Find out what is the exact file requested $file = FALSE; foreach ($possible_files as $name) { @@ -24,7 +28,7 @@ foreach ($possible_files as $name) { // No downloadable file found if ($file === FALSE) { - site_header("Download not found"); + site_header("Download not found", $site_config); $info = "<p> The file you requested (<strong> " . htmlspecialchars($df, ENT_QUOTES, "UTF-8") . " </strong>) is not found on @@ -47,36 +51,30 @@ EOT; $local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file; // Print out common header -site_header('Get Download'); +site_header('Get Download', $site_config); ?> +<div id="mirrors-container"> <h1>Choose mirror site for download</h1> <p> You have chosen to download the following file: + <strong class="filename"><?php echo $df ?></strong><br /> </p> -<div class="center"> -<table border="0" cellpadding="10" cellspacing="1" width="500"> -<tr bgcolor="#cccccc"><td align="center"> -<?php -echo '<strong>' . $df . '</strong><br />'; - +<?php // Try to get filesize to display $size = @filesize($local_file); if ($size) { echo '<small>' . number_format($size, 0, '.', ',') . ' bytes</small><br />'; } ?> -</td></tr></table> + + <div class="mirrors-list"> +<?php print_full_mirror_list($df); ?> + </div> </div> -<p> - Please choose the mirror closest to you from which to download the file. - The current mirror is highlighted in yellow, mirror sites detected to be - out of date or dysfunctional are not listed for your convenience. -</p> - -<?php -mirror_list($df); -site_footer(); + +<?php site_footer(); + diff --git a/include/mirrortable.inc b/include/mirrortable.inc deleted file mode 100644 index babe5aa..0000000 --- a/include/mirrortable.inc +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/* $Id$ */ - -/* - This file includes functions to find close mirrors and list - the sites in to tables below each other. First is the close - mirror's table (sites in the same country as the user), second - is the other mirror's table. - - Include this file only if you are going to output a page which - should list mirror sites. -*/ - -// If we have a valid country, and we have at least one mirror -// in that country, provide some intro text and the list of -// close mirrors, and other mirrors -function mirror_list($df = '') { - - global $COUNTRY; - - // Valid country code present in $COUNTRY - if (i2c_valid_country()) { - - // Count number of active mirrors in this country - $close = count_mirrors($COUNTRY); - - // There is at least one close mirror - if ($close > 0) { - - // Print out close mirrors' table - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "<p>\n We have automatically detected the following $mnum to be close\n" . - " to you. If you use a mirror close to you for downloads and\n" . - " your usual daily work, you will get better response times.\n</p>\n"; - mirror_table($df, $COUNTRY); - - // Print out table of other mirror sites - echo "<p>\n Here is the list of all the other sites in case our detection\n" . - " did something wrong, or the local mirror sites are busy.\n</p>\n"; - mirror_table($df, '', $COUNTRY); - } else { mirror_table($df); } - } else { mirror_table($df); } -} - -// List mirrors, possibly restricted -function mirror_table($df = '', $cmatch = '', $cnomatch = '') { - - global $MIRRORS, $COUNTRIES, $MYSITE; - - // Configure the table based on whether this is a download - // table or a usual mirror listing table - if (!empty($df)) { - $cnf = array( - 'virtual' => TRUE, - 'datacols' => 2, - 'download' => TRUE - ); - } else { - $cnf = array( - 'virtual' => FALSE, - 'datacols' => 2, - 'download' => FALSE - ); - } - - echo "<div class=\"center\">\n" . - " <table border=\"0\" cellpadding=\"3\" class=\"mirrors\">\n"; - - // Previous mirror country code - $prevcc = 'aa'; - - // Go through all mirror sites and print out information about them - $MURLS = array_keys($MIRRORS); - foreach ($MURLS as $murl) { - - // If the mirror is not all right or it is virtual (not an official mirror), or if this is an IP, skip it - if (mirror_status($murl) != MIRROR_OK || - (!$cnf['virtual'] && mirror_type($murl) == MIRROR_VIRTUAL) || preg_match('/^\d/',$murl)) { continue; } - - // Get the country code and check if it is - // matching the country provided (or does not - // match the country, which it should not be) - $country = mirror_country($murl); - if (!empty($cmatch) && $country != $cmatch) { continue; } - if (!empty($cnomatch) && $country == $cnomatch) { continue; } - - // Print out a country header, if a new country is found - if ($prevcc != $country && $country != "xx") { - echo " <tr>\n <th class=\"flag\">"; - if ($country == 'xxx') { - echo " "; - } else { - print_image( - 'flags/' . strtolower($country) . '.png', - $COUNTRIES[$country] - ); - } - echo "</th>\n" . - ' <th class="ch" colspan="' . $cnf['datacols'] . '">' . - $COUNTRIES[$country] . "</th>\n </tr>\n"; - } - - // We print out a row for the current mirror - $thismirror = ($MYSITE == $murl); - - // Highlight this mirror if it is the current one - echo " <tr" . ($thismirror ? " class=\"this\"" : "") . ">\n"; - - // Print out caret (in bold if current mirror) - echo ' <td class="caret">'; - print_image(($thismirror ? 'caret-r.gif' : 'caret-rg.gif')); - echo "</td>\n"; - - // Get short name of the mirror site - $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); - - // If this is a download table print out download links - if ($cnf['download']) { - // Print out mirror site download link - echo ' <td>'; - $mirrorname = ($thismirror ? "this" : $mirrorshort); - print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); - echo "</td>\n"; - - // Print out mirror provider's name - echo ' <td>' . htmlspecialchars(mirror_provider($murl)) . "</td>\n"; - } - - // If this is a normal table, print out information - else { - // Print out mirror site and provider link - echo " <td><a href=\"$murl\">$mirrorshort</a></td>\n" . - " <td><a href=\"" . - mirror_provider_url($murl) . "\">" . - htmlspecialchars(mirror_provider($murl)) . - "</a></td>\n"; - } - - // End row for this mirror - echo " </tr>\n"; - - // Maintain previous country code - $prevcc = $country; - } - echo " </table>\n</div>"; -} diff --git a/include/site.inc b/include/site.inc index 31b7e0b..c930534 100644 --- a/include/site.inc +++ b/include/site.inc @@ -189,6 +189,72 @@ function mirror_setcookie($name, $content, $exptime) } } +function organise_mirrors($mirrors) { + // Lets group the mirrors by country code, for easy output on the page. + $retval = array(); + foreach($mirrors as $key => $mirror) { + + // If the mirror is not all right or it is virtual (not an official mirror), skip it + if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; } + + if(!isset($grouped_mirrors[$mirror[0]])) { + $grouped_mirrors[$mirror[0]] = array(); + } + + $retval[$mirror[0]][] = array( + 'url' => $key, + 'country_code' => $mirror[0], + 'provider_title' => $mirror[1], + 'provider_url' => $mirror[3] + ); + + } + return $retval; +} +function print_full_mirror_list($download_file = null) { + global $COUNTRIES, $COUNTRY, $MIRRORS; + + $groupped = organise_mirrors($MIRRORS); + $close = count_mirrors($COUNTRY); + if ($close) { + $mnum = (($close > 1) ? "mirrors" : "mirror"); + echo "<p>We have automatically detected the following $mnum to be close to you</p>"; + + if (isset($groupped[$COUNTRY])) { + print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $groupped[$COUNTRY], $download_file, true); + echo "<br />"; + } + } + foreach($groupped as $mirrorcode => $country) { + print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country, $download_file, false); + } +} + +function print_mirror_box($countryname, $countrycode, $mirrors, $file = null, $homecountry = false) { +?> + <div class="mirror <?php echo $homecountry ? "homecountry" : ""?>"> + <div class="title"><?php echo $countryname; ?> + <img alt="<?php echo $countrycode; ?>" + height="25" + width="45" + src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>"> + </div> + <?php foreach($mirrors as $mirror): ?> +<?php + $url = substr($mirror["url"], strpos($mirror["url"], '//') + 2, -1); + if ($file) { + $url = "/get/$file/from/$url/mirror"; + } +?> + <div class="entry"> + <div class="url"><a href="<?php echo $url; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div> + <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> + </div> + <?php endforeach; ?> + </div> +<?php +} + // Use this function to write out proper headers on // pages where the content should not be publicly cached function header_nocache() diff --git a/mirrors.php b/mirrors.php index f307380..5e0b99c 100644 --- a/mirrors.php +++ b/mirrors.php @@ -10,45 +10,7 @@ $header_config = array( ); site_header("Mirror Sites", $header_config); -function print_mirror_box($countryname, $countrycode, $country, $homecountry = false) { -?> - <div class="mirror <?php echo $homecountry ? "homecountry" : ""?>"> - <div class="title"><?php echo $countryname; ?> - <img alt="<?php echo $countrycode; ?>" - height="25" - width="45" - src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>"> - </div> - <?php foreach($country as $mirror): ?> - <div class="entry"> - <div class="url"><a href="<?php echo $mirror['url']; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div> - <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> - </div> - <?php endforeach; ?> - </div> -<?php -} - -// Lets group the mirrors by country code, for easy output on the page. -$grouped_mirrors = array(); -foreach($MIRRORS as $key => $mirror) { - - // If the mirror is not all right or it is virtual (not an official mirror), skip it - if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; } - - if(!isset($grouped_mirrors[$mirror[0]])) { - $grouped_mirrors[$mirror[0]] = array(); - } - $grouped_mirrors[$mirror[0]][] = array( - 'url' => $key, - 'country_code' => $mirror[0], - 'provider_title' => $mirror[1], - 'provider_url' => $mirror[3] - ); -} - -$close = count_mirrors($COUNTRY); ?> <div id="mirrors-container"> @@ -74,21 +36,7 @@ $close = count_mirrors($COUNTRY); </div> <div class="mirrors-list"> -<?php if ($close) { - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "<p>We have automatically detected the following $mnum to be close to you</p>"; - - if (isset($grouped_mirrors[$COUNTRY])) { - print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $grouped_mirrors[$COUNTRY], 1); - echo "<br />"; - } -} -?> - - <?php foreach($grouped_mirrors as $mirrorcode => $country): ?> - <?php print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country) ?> - <?php endforeach ?> - + <?php print_full_mirror_list() ?> </div> </div> diff --git a/styles/mirror.css b/styles/mirror.css index 0b8ffc8..92efd8f 100644 --- a/styles/mirror.css +++ b/styles/mirror.css @@ -45,6 +45,15 @@ div#usernotes a.usernotes-voted:hover { font-size: 1.7em; } +#mirrors-container .filename { + display: block; + padding: 20px; + border: 1px; + font-size: 1.4em; + background-color: #EEE; + text-align: center; +} + #mirrors-container .mirrors-list .mirror { display: inline-block; @@ -59,10 +68,12 @@ div#usernotes a.usernotes-voted:hover { display: block; margin: 5px auto; height: 100%; + background-color: #9C9; + padding: 20px 20px 40px 20px; } #mirrors-container .mirrors-list .mirror:hover { - background-color: #EEE; + background-color: #9C9; } #mirrors-container .mirrors-list .mirror .url {
diff --git a/include/get-download.inc b/include/get-download.inc index d1ca357..f46d73e 100644 --- a/include/get-download.inc +++ b/include/get-download.inc @@ -1,6 +1,5 @@ <?php // $Id$ -include_once $_SERVER['DOCUMENT_ROOT'] . '/include/mirrortable.inc'; // Try to make this page non-cached header_nocache(); @@ -13,6 +12,11 @@ if (!isset($df)) { // Could be a normal download or a manual download file $possible_files = array($df, "manual/$df"); +$site_config = array( + 'current' => 'downloads', + 'css' => array('mirror.css') +); + // Find out what is the exact file requested $file = FALSE; foreach ($possible_files as $name) { @@ -24,7 +28,7 @@ foreach ($possible_files as $name) { // No downloadable file found if ($file === FALSE) { - site_header("Download not found"); + site_header("Download not found", $site_config); $info = "<p> The file you requested (<strong> " . htmlspecialchars($df, ENT_QUOTES, "UTF-8") . " </strong>) is not found on @@ -47,36 +51,30 @@ EOT; $local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file; // Print out common header -site_header('Get Download'); +site_header('Get Download', $site_config); ?> +<div id="mirrors-container"> <h1>Choose mirror site for download</h1> <p> You have chosen to download the following file: + <strong class="filename"><?php echo $df ?></strong><br /> </p> -<div class="center"> -<table border="0" cellpadding="10" cellspacing="1" width="500"> -<tr bgcolor="#cccccc"><td align="center"> -<?php -echo '<strong>' . $df . '</strong><br />'; - +<?php // Try to get filesize to display $size = @filesize($local_file); if ($size) { echo '<small>' . number_format($size, 0, '.', ',') . ' bytes</small><br />'; } ?> -</td></tr></table> + + <div class="mirrors-list"> +<?php print_full_mirror_list($df); ?> + </div> </div> -<p> - Please choose the mirror closest to you from which to download the file. - The current mirror is highlighted in yellow, mirror sites detected to be - out of date or dysfunctional are not listed for your convenience. -</p> - -<?php -mirror_list($df); -site_footer(); + +<?php site_footer(); + diff --git a/include/mirrortable.inc b/include/mirrortable.inc deleted file mode 100644 index babe5aa..0000000 --- a/include/mirrortable.inc +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/* $Id$ */ - -/* - This file includes functions to find close mirrors and list - the sites in to tables below each other. First is the close - mirror's table (sites in the same country as the user), second - is the other mirror's table. - - Include this file only if you are going to output a page which - should list mirror sites. -*/ - -// If we have a valid country, and we have at least one mirror -// in that country, provide some intro text and the list of -// close mirrors, and other mirrors -function mirror_list($df = '') { - - global $COUNTRY; - - // Valid country code present in $COUNTRY - if (i2c_valid_country()) { - - // Count number of active mirrors in this country - $close = count_mirrors($COUNTRY); - - // There is at least one close mirror - if ($close > 0) { - - // Print out close mirrors' table - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "<p>\n We have automatically detected the following $mnum to be close\n" . - " to you. If you use a mirror close to you for downloads and\n" . - " your usual daily work, you will get better response times.\n</p>\n"; - mirror_table($df, $COUNTRY); - - // Print out table of other mirror sites - echo "<p>\n Here is the list of all the other sites in case our detection\n" . - " did something wrong, or the local mirror sites are busy.\n</p>\n"; - mirror_table($df, '', $COUNTRY); - } else { mirror_table($df); } - } else { mirror_table($df); } -} - -// List mirrors, possibly restricted -function mirror_table($df = '', $cmatch = '', $cnomatch = '') { - - global $MIRRORS, $COUNTRIES, $MYSITE; - - // Configure the table based on whether this is a download - // table or a usual mirror listing table - if (!empty($df)) { - $cnf = array( - 'virtual' => TRUE, - 'datacols' => 2, - 'download' => TRUE - ); - } else { - $cnf = array( - 'virtual' => FALSE, - 'datacols' => 2, - 'download' => FALSE - ); - } - - echo "<div class=\"center\">\n" . - " <table border=\"0\" cellpadding=\"3\" class=\"mirrors\">\n"; - - // Previous mirror country code - $prevcc = 'aa'; - - // Go through all mirror sites and print out information about them - $MURLS = array_keys($MIRRORS); - foreach ($MURLS as $murl) { - - // If the mirror is not all right or it is virtual (not an official mirror), or if this is an IP, skip it - if (mirror_status($murl) != MIRROR_OK || - (!$cnf['virtual'] && mirror_type($murl) == MIRROR_VIRTUAL) || preg_match('/^\d/',$murl)) { continue; } - - // Get the country code and check if it is - // matching the country provided (or does not - // match the country, which it should not be) - $country = mirror_country($murl); - if (!empty($cmatch) && $country != $cmatch) { continue; } - if (!empty($cnomatch) && $country == $cnomatch) { continue; } - - // Print out a country header, if a new country is found - if ($prevcc != $country && $country != "xx") { - echo " <tr>\n <th class=\"flag\">"; - if ($country == 'xxx') { - echo " "; - } else { - print_image( - 'flags/' . strtolower($country) . '.png', - $COUNTRIES[$country] - ); - } - echo "</th>\n" . - ' <th class="ch" colspan="' . $cnf['datacols'] . '">' . - $COUNTRIES[$country] . "</th>\n </tr>\n"; - } - - // We print out a row for the current mirror - $thismirror = ($MYSITE == $murl); - - // Highlight this mirror if it is the current one - echo " <tr" . ($thismirror ? " class=\"this\"" : "") . ">\n"; - - // Print out caret (in bold if current mirror) - echo ' <td class="caret">'; - print_image(($thismirror ? 'caret-r.gif' : 'caret-rg.gif')); - echo "</td>\n"; - - // Get short name of the mirror site - $mirrorshort = substr($murl, strpos($murl, '//') + 2, -1); - - // If this is a download table print out download links - if ($cnf['download']) { - // Print out mirror site download link - echo ' <td>'; - $mirrorname = ($thismirror ? "this" : $mirrorshort); - print_link("/get/$df/from/$mirrorname/mirror", $mirrorshort); - echo "</td>\n"; - - // Print out mirror provider's name - echo ' <td>' . htmlspecialchars(mirror_provider($murl)) . "</td>\n"; - } - - // If this is a normal table, print out information - else { - // Print out mirror site and provider link - echo " <td><a href=\"$murl\">$mirrorshort</a></td>\n" . - " <td><a href=\"" . - mirror_provider_url($murl) . "\">" . - htmlspecialchars(mirror_provider($murl)) . - "</a></td>\n"; - } - - // End row for this mirror - echo " </tr>\n"; - - // Maintain previous country code - $prevcc = $country; - } - echo " </table>\n</div>"; -} diff --git a/include/site.inc b/include/site.inc index 31b7e0b..c930534 100644 --- a/include/site.inc +++ b/include/site.inc @@ -189,6 +189,72 @@ function mirror_setcookie($name, $content, $exptime) } } +function organise_mirrors($mirrors) { + // Lets group the mirrors by country code, for easy output on the page. + $retval = array(); + foreach($mirrors as $key => $mirror) { + + // If the mirror is not all right or it is virtual (not an official mirror), skip it + if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; } + + if(!isset($grouped_mirrors[$mirror[0]])) { + $grouped_mirrors[$mirror[0]] = array(); + } + + $retval[$mirror[0]][] = array( + 'url' => $key, + 'country_code' => $mirror[0], + 'provider_title' => $mirror[1], + 'provider_url' => $mirror[3] + ); + + } + return $retval; +} +function print_full_mirror_list($download_file = null) { + global $COUNTRIES, $COUNTRY, $MIRRORS; + + $groupped = organise_mirrors($MIRRORS); + $close = count_mirrors($COUNTRY); + if ($close) { + $mnum = (($close > 1) ? "mirrors" : "mirror"); + echo "<p>We have automatically detected the following $mnum to be close to you</p>"; + + if (isset($groupped[$COUNTRY])) { + print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $groupped[$COUNTRY], $download_file, true); + echo "<br />"; + } + } + foreach($groupped as $mirrorcode => $country) { + print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country, $download_file, false); + } +} + +function print_mirror_box($countryname, $countrycode, $mirrors, $file = null, $homecountry = false) { +?> + <div class="mirror <?php echo $homecountry ? "homecountry" : ""?>"> + <div class="title"><?php echo $countryname; ?> + <img alt="<?php echo $countrycode; ?>" + height="25" + width="45" + src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>"> + </div> + <?php foreach($mirrors as $mirror): ?> +<?php + $url = substr($mirror["url"], strpos($mirror["url"], '//') + 2, -1); + if ($file) { + $url = "/get/$file/from/$url/mirror"; + } +?> + <div class="entry"> + <div class="url"><a href="<?php echo $url; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div> + <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> + </div> + <?php endforeach; ?> + </div> +<?php +} + // Use this function to write out proper headers on // pages where the content should not be publicly cached function header_nocache() diff --git a/mirrors.php b/mirrors.php index f307380..5e0b99c 100644 --- a/mirrors.php +++ b/mirrors.php @@ -10,45 +10,7 @@ $header_config = array( ); site_header("Mirror Sites", $header_config); -function print_mirror_box($countryname, $countrycode, $country, $homecountry = false) { -?> - <div class="mirror <?php echo $homecountry ? "homecountry" : ""?>"> - <div class="title"><?php echo $countryname; ?> - <img alt="<?php echo $countrycode; ?>" - height="25" - width="45" - src="<?php echo $_SERVER['STATIC_ROOT'] . '/images/flags/beta/' . strtolower($countrycode) . '.png'; ?>"> - </div> - <?php foreach($country as $mirror): ?> - <div class="entry"> - <div class="url"><a href="<?php echo $mirror['url']; ?>" title="<?php echo clean($mirror['url']); ?>"><?php echo clean($mirror['url']); ?></a></div> - <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> - </div> - <?php endforeach; ?> - </div> -<?php -} - -// Lets group the mirrors by country code, for easy output on the page. -$grouped_mirrors = array(); -foreach($MIRRORS as $key => $mirror) { - - // If the mirror is not all right or it is virtual (not an official mirror), skip it - if (mirror_status($key) != MIRROR_OK || mirror_type($key) == MIRROR_VIRTUAL) { continue; } - - if(!isset($grouped_mirrors[$mirror[0]])) { - $grouped_mirrors[$mirror[0]] = array(); - } - $grouped_mirrors[$mirror[0]][] = array( - 'url' => $key, - 'country_code' => $mirror[0], - 'provider_title' => $mirror[1], - 'provider_url' => $mirror[3] - ); -} - -$close = count_mirrors($COUNTRY); ?> <div id="mirrors-container"> @@ -74,21 +36,7 @@ $close = count_mirrors($COUNTRY); </div> <div class="mirrors-list"> -<?php if ($close) { - $mnum = (($close > 1) ? "mirrors" : "mirror"); - echo "<p>We have automatically detected the following $mnum to be close to you</p>"; - - if (isset($grouped_mirrors[$COUNTRY])) { - print_mirror_box($COUNTRIES[$COUNTRY], $COUNTRY, $grouped_mirrors[$COUNTRY], 1); - echo "<br />"; - } -} -?> - - <?php foreach($grouped_mirrors as $mirrorcode => $country): ?> - <?php print_mirror_box($COUNTRIES[$mirrorcode], $mirrorcode, $country) ?> - <?php endforeach ?> - + <?php print_full_mirror_list() ?> </div> </div> diff --git a/styles/mirror.css b/styles/mirror.css index 0b8ffc8..92efd8f 100644 --- a/styles/mirror.css +++ b/styles/mirror.css @@ -45,6 +45,15 @@ div#usernotes a.usernotes-voted:hover { font-size: 1.7em; } +#mirrors-container .filename { + display: block; + padding: 20px; + border: 1px; + font-size: 1.4em; + background-color: #EEE; + text-align: center; +} + #mirrors-container .mirrors-list .mirror { display: inline-block; @@ -59,10 +68,12 @@ div#usernotes a.usernotes-voted:hover { display: block; margin: 5px auto; height: 100%; + background-color: #9C9; + padding: 20px 20px 40px 20px; } #mirrors-container .mirrors-list .mirror:hover { - background-color: #EEE; + background-color: #9C9; } #mirrors-container .mirrors-list .mirror .url {