From c5d0c2728c113f8e2364d501bed0e23f7748af27 Mon Sep 17 00:00:00 2001 From: filip Date: Sun, 28 Jun 2015 22:45:38 +0200 Subject: mga 5 pdf and epub documenation files added + improvements: - more clear page - links added only for present pdf and epub files - function doc_list improved and cleaned --- en/doc/archive.php | 6 ++-- en/doc/doc.php | 82 +++++++++++++++++++++++++++++++++++++++--------------- en/doc/index.php | 24 +++------------- 3 files changed, 67 insertions(+), 45 deletions(-) (limited to 'en/doc') diff --git a/en/doc/archive.php b/en/doc/archive.php index 387a4cd06..9aff8cc64 100644 --- a/en/doc/archive.php +++ b/en/doc/archive.php @@ -29,19 +29,19 @@ require 'doc.php';

Mageia 3

HTML'); + doc_list(_r('Installer'), 'installer', 3); ?>

HTML'); + doc_list(_r('Control Center'), 'control_center', 3); ?>


Mageia 2

HTML'); + doc_list(_r('Installer'), 'installer', 2); ?>

diff --git a/en/doc/doc.php b/en/doc/doc.php index 285c43dec..ddcb016a9 100644 --- a/en/doc/doc.php +++ b/en/doc/doc.php @@ -11,67 +11,105 @@ $documentation['control_center'][3] = array('en','et','fr'); $documentation['installer' ][2] = array('de','el','en','eo','fr','nl','pt_br','uk'); +$defs = parse_ini_file('../downloads/get/definitions_doc.ini', true); + +function pdf_epub_present_in_locale($doc_name, $lang, $extension) +{ + global $defs; + + $eng_file_name = sprintf('%s_en_%s', $doc_name, $extension); + if(array_key_exists($eng_file_name, $defs)) { + $langs = explode('|', $defs[$eng_file_name]['langs']); + if (in_array($lang, $langs)) { + return TRUE; + } + } + return FALSE; +} + function doc_present_in_locale($documentation_name, $version) { global $locale; global $documentation; $link_locale = locale_hyphen_underscore($locale); // create pt_br.po from pt-br and alike - if(in_array($link_locale, $documentation[$documentation_name][$version])) { + if (in_array($link_locale, $documentation[$documentation_name][$version])) { return $link_locale; } else { return 'en'; } } -function doc_list($documentation_name, $type, $version, $link, $epub_link = null, $pdf_link = null) +function doc_list($documentation_name, $type, $version) { global $locale; global $langs; global $documentation; + + if ('control_center' == $type) { + $dir = 'mcc'; + $name = 'MCC'; + $title = _r('Control Center'); + } else if ('installer' == $type) { + $dir = 'installer'; + $name = 'DrakX'; + $title = _r('Installer'); + } else { + return; // proper $type not defined ;) + } + + $doc_link = sprintf('%s', $dir, $version, '%s', '%s'); + $pdf_link = sprintf('PDF', $version, $name, '%s', $title); + $epub_link = sprintf('EPUB', $version, $name, '%s', $title); + $link_locale = locale_hyphen_underscore($locale); // create pt_br.po from pt-br and alike $your_language = ''; - $others = ''; + $others = array(); $text_others = ''; $your_language_present = FALSE; $other_languages_present = FALSE; $note_printed = FALSE; - // temporary hidding of the EPUB and PDF links - $hide_epub_pdf = FALSE; $table = PHP_EOL . '' . PHP_EOL; -// $table .= ''; $table .= "\t" . PHP_EOL; foreach ($documentation[$type][$version] as $lng) { // hopefully temporary exception for pt-br as convention for lang-abbrev in /langs.inc.php is different as link in doc.mageia.org - if ($lng == 'pt_br') { - $lng_name = $langs['pt-br']; - } else { - $lng_name = $langs[$lng]; + $lng_name = $langs[locale_underscore_to_hyphen($lng)]; + + $pdf_present = pdf_epub_present_in_locale(sprintf('Mageia%s_%s', $version, $name), $lng, 'pdf'); + $epub_present = pdf_epub_present_in_locale(sprintf('Mageia%s_%s', $version, $name), $lng, 'epub'); + $pdf_epub_links = array(); + if ($pdf_present) { + $pdf_epub_links[] = sprintf($pdf_link, $lng); + } + if ($epub_present) { + $pdf_epub_links[] = sprintf($epub_link, $lng); } + $pdf_epub_links = implode(', ', $pdf_epub_links); + $lang_doc_link = sprintf($doc_link, $lng, $lng_name); if ($link_locale == $lng) { $your_language_present = TRUE; - if (is_null($epub_link) or is_null($pdf_link) or $hide_epub_pdf) { - $your_language = sprintf(_r('%s available in %s') . '
%s', - '' . $documentation_name . '', $lng_name, sprintf($link, $lng)); + if (!$pdf_present && !$epub_present) { + $your_language = sprintf(_r('Online manual for %s available in %s') . '
', + '' . $documentation_name . '', $lang_doc_link); } else { - $your_language = sprintf(_r('%s available in %s') . '
%s ('. - _r('also as') . ' %s, %s)', + $your_language = sprintf(_r('Online manual for %s available in %s') . '
('. + _r('also as file:') . ' %s)', '' . $documentation_name . '', - $lng_name, sprintf($link, $lng), sprintf($epub_link, $lng), sprintf($pdf_link, $lng)); + $lang_doc_link, $pdf_epub_links); } } else { $other_languages_present = TRUE; - if (is_null($epub_link) or is_null($pdf_link) or $hide_epub_pdf) { - $others[] = sprintf('%s
%s', $lng_name, sprintf($link, $lng)); + if (!$pdf_present && !$epub_present) { + $others[] = $lang_doc_link; } else { if(!$note_printed) { - $note = _r('also as') . ' '; + $note = _r('also as file:', ' '); $note_printed = TRUE; } else { $note = ''; } - $others[] = sprintf('%s
%s (%s%s, %s)', - $lng_name, sprintf($link, $lng), $note, sprintf($epub_link, $lng), sprintf($pdf_link, $lng), sprintf($link, $lng)); + $others[] = sprintf('%s (%s%s)', + $lang_doc_link, $note, $pdf_epub_links, $lang_doc_link); } } } @@ -89,7 +127,7 @@ function doc_list($documentation_name, $type, $version, $link, $epub_link = null if($single_version < $version && in_array($link_locale, $all_languages)) { $language_present_before = "\t\t" . PHP_EOL; + $lng_name, $documentation_name, $single_version) . "" . PHP_EOL; break; } else { $language_present_before = ''; diff --git a/en/doc/index.php b/en/doc/index.php index fe7e68f22..2730d5bce 100644 --- a/en/doc/index.php +++ b/en/doc/index.php @@ -32,35 +32,19 @@ require 'doc.php';

Mageia 5

-

HTML'); -# doc_list(_r('Installer'), 'installer', 5, 'HTML', -# 'EPUB', -# 'PDF'); - ?>

+

-

HTML'); -# doc_list(_r('Control Center'), 'control_center', 5, 'HTML', -# 'EPUB', -# 'PDF'); - ?>

+


Mageia 4

-

HTML', - 'EPUB', - 'PDF'); +

-

HTML', - 'EPUB', - 'PDF'); +

-- cgit v1.2.1
" . sprintf(_r('Translation was present in %s before.
Maybe you can check documentation for %s in Mageia %s.'), - $langs[$locale], $documentation_name, $single_version) . "