0; $bReferenceOnly = count($aReferenceOnly) > 0; // Display results if ($bFileOnly || $bReferenceOnly) { printf("[%s]\n", $sGallery); } if ($bFileOnly) { printf(" files:\n - %s\n", implode("\n - ", $aFileOnly)); if ($bFix) { $aFix = []; foreach ($aFileOnly as $sPhoto) { $sPhotoFile = sprintf('%s%s%s%s%s.md', $sFixDir, DIRECTORY_SEPARATOR, $sGallery, DIRECTORY_SEPARATOR, $sPhoto); if (!file_exists($sPhotoFile)) { printf(" <%s> non existent!\n", $sPhoto); continue; } parseFile($sPhotoFile, $aPhotoYaml); unset($aPhotoYaml['gallery']); unset($aPhotoYaml['layout']); unset($aPhotoYaml['next']); unset($aPhotoYaml['ordering']); unset($aPhotoYaml['previous']); unset($aPhotoYaml['sizes']); unset($aPhotoYaml['title']); if (!isset($aPhotoYaml['date'])) { printf(" <%s> no date!\n", $sPhoto); continue; } else { $aPhotoYaml['date'] = date('Y-m-d H:i:s', $aPhotoYaml['date']); } if (isset($aPhotoYaml['location'])) { $aPhotoYaml = array_merge($aPhotoYaml, $aPhotoYaml['location']); unset($aPhotoYaml['location']); } $aFix[$sPhoto] = $aPhotoYaml; } $sFix = substr(yamlDump(array('' => $aFix)), 1); file_put_contents($sFile, trim(sprintf("%s%s", file_get_contents($sFile), $sFix))); } } if ($bReferenceOnly) { printf(" references:\n - %s\n", implode("\n - ", $aReferenceOnly)); } }