From e31ec4507c495254239f11841d81c865e80e41a9 Mon Sep 17 00:00:00 2001 From: filip Date: Sat, 2 May 2015 16:13:53 +0200 Subject: adding download of pdf and epub file infrastructure --- en/downloads/get/index.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'en/downloads/get/index.php') diff --git a/en/downloads/get/index.php b/en/downloads/get/index.php index 0678b9f0a..fc4497f98 100644 --- a/en/downloads/get/index.php +++ b/en/downloads/get/index.php @@ -37,6 +37,7 @@ require 'lib.php'; // request $product = get('q'); +$doc = get('doc'); $debug = get('d'); if (isset($_GET['torrent'])) { $torrent = strip_tags(trim($_GET['torrent'])); @@ -58,14 +59,31 @@ session_start(); $download = null; $js_redirect = null; $reason = null; +if ($doc == 'yes') { + $def_file = 'definitions_doc.ini'; + list($release, $type, $lang, $extension) = explode('_', $product); // 'Mageia4_DrakX_en_epub' + $product = implode('_', array($release, $type, 'en', $extension)); + $documentation = true; +} else { + $def_file = 'definitions.ini'; + $documentation = false; +} try { // TODO simplify and wrap all this in a single interface: // list(dl_template, mirrors) = get_download_options_for(product) // Step 1. include '../../../lib/Downloads.php'; - $product = get_info_for_product($product); - $all_mirrors = get_mirrors_for($product['file'], 'en', get('country')); + $product = get_info_for_product($product, $def_file); + if ($doc == 'yes') { + $langs = explode('|', $product['langs']); + if (!in_array($lang, $langs)) { + $lang = 'en'; // fallback language + } + $product['file'] = $release . '-' . $type . '-' . $lang . '.' . $extension; + $product['name'] = $product['file']; + } + $all_mirrors = get_mirrors_for($product['file'], 'en', get('country'), true, $documentation); $one_mirror = $all_mirrors[0]; $alt_mirrors = $all_mirrors[1]; $download_tmpl = get_download_link($product, $torrent); -- cgit v1.2.1