Add per-article hide-map toggle for index while keeping admin map visible
This commit is contained in:
parent
5e483b4593
commit
752565a7a4
2 changed files with 50 additions and 3 deletions
14
index.php
14
index.php
|
|
@ -47,6 +47,16 @@ function hidden_video_outputs($config){
|
|||
return $hidden;
|
||||
}
|
||||
|
||||
function map_hidden_outputs($config){
|
||||
$hidden = [];
|
||||
foreach (glob($config['uploads_dir'].'/*', GLOB_ONLYDIR) ?: [] as $dir) {
|
||||
if (!is_file($dir . '/.mvlog-hide-map')) continue;
|
||||
$state = is_file($dir . '/.movmaker-state.json') ? json_decode((string)file_get_contents($dir . '/.movmaker-state.json'), true) : [];
|
||||
if (is_array($state) && !empty($state['output'])) $hidden[basename((string)$state['output'])] = true;
|
||||
}
|
||||
return $hidden;
|
||||
}
|
||||
|
||||
function video_metadata($path){
|
||||
$base = pathinfo($path, PATHINFO_FILENAME);
|
||||
$meta = [
|
||||
|
|
@ -134,6 +144,7 @@ function load_video_cache($videos){
|
|||
}
|
||||
|
||||
$hiddenOutputs = hidden_video_outputs($config);
|
||||
$hiddenMapOutputs = map_hidden_outputs($config);
|
||||
$videos = array_values(array_filter(
|
||||
glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [],
|
||||
fn($v)=>empty($hiddenOutputs[basename($v)]) && !preg_match('/_preview\.(mp4|webm|mov|m4v)$/i', basename($v))
|
||||
|
|
@ -289,7 +300,8 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
|
|||
<video controls controlsList="nodownload" oncontextmenu="return false" preload="metadata" src="<?=h($url)?>"></video>
|
||||
<?php
|
||||
$map = pathinfo($name, PATHINFO_FILENAME).".png";
|
||||
if(is_file($config['videos_dir']."/".$map)):
|
||||
$hideMap = !empty($hiddenMapOutputs[$name]);
|
||||
if(!$hideMap && is_file($config['videos_dir']."/".$map)):
|
||||
?>
|
||||
<a class="map-image-link" href="<?=h($config['public_videos']."/".rawurlencode($map))?>"><img class="map-image" src="<?=h($config['public_videos']."/".rawurlencode($map))?>" alt="Map"></a>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue