From 67312e7b378be5fb464f0748bbe949d977a0e894 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 11 Jan 2019 16:50:35 +0100 Subject: [serversetup-bwlp] Implement download page --- modules-available/serversetup-bwlp/page.inc.php | 40 ++++++++++++++++++++-- .../serversetup-bwlp/templates/download.html | 23 ++++++++----- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 004077dc..b9732d2b 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -176,8 +176,44 @@ class Page_ServerSetup extends Page private function showDownload() { - // TODO: Make nicer, support more variants (taskmanager-plugin) - Render::addTemplate('download'); + $list = glob('/srv/openslx/www/boot/download/*', GLOB_NOSORT); + usort($list, function ($a, $b) { + return strcmp(substr($a, -4), substr($b, -4)) * 100 + strcmp($a, $b); + }); + $files = []; + $strings = [ + 'efi' => [Dictionary::translate('dl-efi', true) => 50], + 'pcbios' => [Dictionary::translate('dl-pcbios', true) => 51], + 'usb' => [Dictionary::translate('dl-usb', true) => 80], + 'hd' => [Dictionary::translate('dl-hd', true) => 81], + 'lkrn' => [Dictionary::translate('dl-lkrn', true) => 82], + 'i386' => [Dictionary::translate('dl-i386', true) => 10], + 'x86_64' => [Dictionary::translate('dl-x86_64', true) => 11], + 'ecm' => [Dictionary::translate('dl-usbnic', true) => 60], + 'ncm' => [Dictionary::translate('dl-usbnic', true) => 61], + 'ipxe' => [Dictionary::translate('dl-pcinic', true) => 62], + 'snp' => [Dictionary::translate('dl-snp', true) => 63], + ]; + foreach ($list as $file) { + if ($file{0} === '.') + continue; + if (is_file($file)) { + $base = basename($file); + $features = []; + foreach (preg_split('/[\-\.\/]+/', $base, -1, PREG_SPLIT_NO_EMPTY) as $p) { + if (array_key_exists($p, $strings)) { + $features += $strings[$p]; + } + } + asort($features); + $files[] = [ + 'name' => $base, + 'class' => substr($base, -4) === '.usb' ? 'slx-bold' : '', + 'features' => implode(', ', array_keys($features)), + ]; + } + } + Render::addTemplate('download', ['files' => $files]); } private function showBootentryList() diff --git a/modules-available/serversetup-bwlp/templates/download.html b/modules-available/serversetup-bwlp/templates/download.html index 6752f7fc..bdb82470 100644 --- a/modules-available/serversetup-bwlp/templates/download.html +++ b/modules-available/serversetup-bwlp/templates/download.html @@ -1,12 +1,17 @@ -