aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2012-05-11 10:45:33 +0000
committerRomain d'Alverny <rda@mageia.org>2012-05-11 10:45:33 +0000
commit2572073a7ec5d63bd9fcc614d1947e0ede8f8170 (patch)
treee524e9e92949a2d26d8c028d875d3aadf4b0a50c
parent611c8e117f4432c0b4fd744cc907aaed5b0662b5 (diff)
downloadwww-2572073a7ec5d63bd9fcc614d1947e0ede8f8170.tar
www-2572073a7ec5d63bd9fcc614d1947e0ede8f8170.tar.gz
www-2572073a7ec5d63bd9fcc614d1947e0ede8f8170.tar.bz2
www-2572073a7ec5d63bd9fcc614d1947e0ede8f8170.tar.xz
www-2572073a7ec5d63bd9fcc614d1947e0ede8f8170.zip
new get_download_link()
-rw-r--r--en/downloads/get/lib.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/en/downloads/get/lib.php b/en/downloads/get/lib.php
index 5217153f0..472a8b7fd 100644
--- a/en/downloads/get/lib.php
+++ b/en/downloads/get/lib.php
@@ -62,9 +62,11 @@ class NoMirrorFoundError extends Exception {}
/**
* TODO use aliases, so that downloads asking for alpha3 get redirected to beta1 for instance? (on migration)
*/
-function get_info_for_product($product)
+function get_info_for_product($product, $def_file = null)
{
- $defs = parse_ini_file('definitions.ini', true);
+ $def_file = is_null($def_file) ? 'definitions.ini' : $def_file;
+
+ $defs = parse_ini_file($def_file, true);
if (array_key_exists($product, $defs)) {
return $defs[$product];
@@ -93,11 +95,33 @@ function get_info_for_product($product)
function get_mirrors_for($file,
$locale = null, $country = null)
{
- include '../../../lib/Downloads.php';
+ //include '../../../lib/Downloads.php';
$mirrors = Downloads::get_all_mirrors();
$wsd = new Downloads();
$one = $wsd->prepare_download(true, $country);
return array($one, $mirrors);
+}
+
+/**
+ * Simplifies things.
+ *
+ * @param array $product, _one_ product definition array, as returned from the definitions.ini
+ * @param boolean $torrent_preferred do we prefer to get a torrent, if available?
+ *
+ * @return string
+*/
+function get_download_link($product, $torrent_preferred = false)
+{
+ if ($torrent_preferred === true
+ && isset($product['torrent'])
+ && strlen($product['torrent']) > 0) {
+
+ $path = $product['torrent'];
+ } else {
+ $path = $product['path'] . '/' . $product['file'];
+ }
+
+ return '$MIRROR/' . $path;
} \ No newline at end of file