improve technical info display

This commit is contained in:
xiaomlove
2021-06-03 11:47:56 +08:00
parent 5c77741e90
commit 272b716f35
+19 -31
View File
@@ -149,47 +149,35 @@ class TechnicalInformation
$videos = array_filter($videos); $videos = array_filter($videos);
$audios = $this->getAudios(); $audios = $this->getAudios();
$subtitles = $this->getSubtitles(); $subtitles = $this->getSubtitles();
//video part // dd($videos, $audios, $subtitles);
$videoTable = '<table style="border: none"><tbody>';
foreach (array_chunk($videos, 2, true) as $row) {
$videoTable .= '<tr>';
foreach ($row as $key => $value) {
$videoTable .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px"><b>%s: </b>%s</td>', $key, $value);
}
$videoTable .= '</tr>';
}
$videoTable .= '</tbody></table>';
$audioTable = '<table style="border: none"><tbody>';
$audioTable .= '<tr>';
foreach ($audios as $key => $value) {
$audioTable .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px"><b>%s: </b>%s</td>', $key, $value);
}
$audioTable .= '</tr>';
$audioTable .= '</tbody></table>';
$subtitleTable = '<table style="border: none"><tbody>';
$subtitleTable .= '<tr>';
foreach ($subtitles as $key => $value) {
$subtitleTable .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px"><b>%s: </b>%s</td>', $key, $value);
}
$subtitleTable .= '</tr>';
$subtitleTable .= '</tbody></table>';
if (empty($videos) && empty($audios) && empty($subtitles)) { if (empty($videos) && empty($audios) && empty($subtitles)) {
return ''; return '';
} }
$result = '<table style="border: none"><tbody><tr>';
$result = '<table style="border: none;width: 100%"><tbody><tr>';
if (!empty($videos)) { if (!empty($videos)) {
$result .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px">%s</td>', $videoTable); $result .= $this->buildTdTable($videos);
} }
if (!empty($audios)) { if (!empty($audios)) {
$result .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px">%s</td>', $audioTable); $result .= $this->buildTdTable($audios);
} }
if (!empty($subtitles)) { if (!empty($subtitles)) {
$result .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px">%s</td>', $subtitleTable); $result .= $this->buildTdTable($subtitles);
} }
$result .= '</tr></tbody></table>'; $result .= '</tr></tbody></table>';
return $result; return $result;
} }
private function buildTdTable(array $parts)
{
$table = '<table style="border: none;"><tbody>';
foreach ($parts as $key => $value) {
$table .= '<tr>';
$table .= sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px;"><b>%s: </b>%s</td>', $key, $value);
$table .= '</tr>';
}
$table .= '</tbody></table>';
return sprintf('<td style="border: none; padding-right: 5px;padding-bottom: 5px">%s</td>', $table);
}
} }