fix $last_update for po4a translated pages
This commit is contained in:
parent
c40470d3de
commit
7e6e053767
1 changed files with 9 additions and 8 deletions
17
mkht.php
17
mkht.php
|
@ -94,12 +94,6 @@ foreach($nodes_cache as $node) {
|
|||
|
||||
$path_parts_src = pathinfo($src);
|
||||
$path_parts_target = pathinfo($target);
|
||||
if (preg_match('#/\.(?!htaccess|well-known)#', $src) !== 0) // Skip hidden nodes other than .htaccess and .well-known
|
||||
continue;
|
||||
if ($node_info->getType() !== 'file')
|
||||
continue;
|
||||
if (in_array('draft', explode('.', $path_parts_target['basename']), true))
|
||||
continue;
|
||||
if (!file_exists($path_parts_target['dirname'])) // Create parent directory if needed
|
||||
mkdir($path_parts_target['dirname'], 0755, true);
|
||||
copy($src, $target);
|
||||
|
@ -125,17 +119,24 @@ foreach ($pages as $node) {
|
|||
$target = str_replace(SITE . 'cache/', SITE . 'target/', $src);
|
||||
$path_parts_src = pathinfo($src);
|
||||
$path_parts_target = pathinfo($target);
|
||||
$lang = $files_langs[$src];
|
||||
|
||||
$file_timestamped = str_replace(SITE . 'cache/', SITE, $src);
|
||||
if (!file_exists($file_timestamped)) {
|
||||
foreach ($pages_langs[$path_parts_src['dirname'] . '/' . $page_names[$src]] as $page_lang) {
|
||||
if (file_exists($file_timestamped = str_replace('.' . $lang . '.', '.' . $page_lang . '.', $file_timestamped)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
$last_update = match (preg_match("/^(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})-/D", $path_parts_src['basename'], $date)) {
|
||||
1 => (new DateTime())->setDate($date['year'], $date['month'], $date['day'])->format('U'),
|
||||
0 => (new SplFileInfo(str_replace(SITE . 'cache/', SITE, $src)))->getMTime(),
|
||||
0 => (new SplFileInfo($file_timestamped))->getMTime(),
|
||||
};
|
||||
|
||||
$base_filepath_src = $path_parts_src['dirname'] . '/' . $path_parts_src['filename'];
|
||||
$base_filepath_target = $path_parts_target['dirname'] . '/' . $path_parts_target['filename'];
|
||||
|
||||
$content = file_get_contents($src);
|
||||
$lang = $files_langs[$src];
|
||||
|
||||
preg_match('/^# (?<title>.*)$/Dm', $content, $matches);
|
||||
$title = $matches['title'] ?? NULL;
|
||||
|
|
Loading…
Reference in a new issue