code fixes

This commit is contained in:
Dennis Eichhorn 2024-03-15 20:24:38 +00:00
parent 094aa4ad30
commit a72fb93533
4 changed files with 19 additions and 17 deletions

View File

@ -262,12 +262,13 @@ final class ApiController extends Controller
->execute(); ->execute();
$ids = \array_map( $ids = \array_map(
function (Report $report) : void { function (Report $report) : int {
$report->resource; return $report->resource;
}, },
$reports $reports
); );
/** @var Resource[] $resources */
$resources = ResourceMapper::getAll() $resources = ResourceMapper::getAll()
->with('owner') ->with('owner')
->with('owner/l11n') ->with('owner/l11n')
@ -333,10 +334,10 @@ final class ApiController extends Controller
$mail->template = \array_merge( $mail->template = \array_merge(
$mail->template, $mail->template,
[ [
'{resource.id}' => $resource->id, '{resource.id}' => (string) $resource->id,
'{email}' => $inform->email, '{email}' => $inform->email,
'{resource.url}' => $resource->uri, '{resource.url}' => $resource->uri,
'{owner_email}' => $resource->owner->getEmail(), '{owner_email}' => $resource->owner->getEmail(),
] ]
); );
@ -612,23 +613,24 @@ final class ApiController extends Controller
$contentNew = \Modules\Media\Controller\ApiController::loadFileContent($newPath, $extension, 'txt', ['path' => $resource->xpath]); $contentNew = \Modules\Media\Controller\ApiController::loadFileContent($newPath, $extension, 'txt', ['path' => $resource->xpath]);
$contentOld = \preg_replace('/(\ {2,}|\t)/', ' ', $contentOld); $contentOld = \preg_replace('/(\ {2,}|\t)/', ' ', $contentOld);
$contentOld = \preg_replace('/(\s{2,})/', "\n", $contentOld); $contentOld = \preg_replace('/(\s{2,})/', "\n", $contentOld ?? '');
$contentNew = \preg_replace('/(\ {2,}|\t)/', ' ', $contentNew); $contentNew = \preg_replace('/(\ {2,}|\t)/', ' ', $contentNew);
$contentNew = \preg_replace('/(\s{2,})/', "\n", $contentNew); $contentNew = \preg_replace('/(\s{2,})/', "\n", $contentNew ?? '');
// Calculate difference index $difference = 1;
$difference = \levenshtein($contentOld, $contentNew); if ($contentNew !== null && $contentOld !== null) {
// Calculate difference index
$difference = \levenshtein($contentOld, $contentNew);
}
$diffPath = \dirname($newPath) . '/_' . \basename($newPath); $diffPath = \dirname($newPath) . '/_' . \basename($newPath);
var_dump($diffPath);
\file_put_contents( \file_put_contents(
$diffPath, $diffPath,
\phpOMS\Utils\StringUtils::createDiffMarkup( \phpOMS\Utils\StringUtils::createDiffMarkup(
$contentOld, $contentOld ?? '',
$contentNew, $contentNew ?? '',
' ' ' '
) )
); );

View File

@ -24,7 +24,7 @@ return ['OnlineResourceWatcher' => [
'BillingSettings' => 'Billing Settings', 'BillingSettings' => 'Billing Settings',
'Bills' => 'Bills', 'Bills' => 'Bills',
'By' => 'By', 'By' => 'By',
'Difference' => 'Unterschiede', 'Difference' => 'Unterschiede',
'Cancel' => 'Cancel', 'Cancel' => 'Cancel',
'Checked' => 'Checked', 'Checked' => 'Checked',
'City' => 'City', 'City' => 'City',

View File

@ -24,7 +24,7 @@ return ['OnlineResourceWatcher' => [
'BillingSettings' => 'Billing Settings', 'BillingSettings' => 'Billing Settings',
'Bills' => 'Bills', 'Bills' => 'Bills',
'By' => 'By', 'By' => 'By',
'Difference' => 'Difference', 'Difference' => 'Difference',
'Cancel' => 'Cancel', 'Cancel' => 'Cancel',
'Checked' => 'Checked', 'Checked' => 'Checked',
'City' => 'City', 'City' => 'City',

View File

@ -69,7 +69,7 @@ use phpOMS\Uri\UriFactory;
} }
} else { } else {
$oldWebPath = '../../../../Web/Backend/img/404.svg'; $oldWebPath = '../../../../Web/Backend/img/404.svg';
$type = 'img'; $type = 'img';
} }
} }
@ -112,7 +112,7 @@ use phpOMS\Uri\UriFactory;
} }
} }
$base = __DIR__ . '/../../../../'; $base = __DIR__ . '/../../../../';
$newDiffPath = ''; $newDiffPath = '';
if ($type === 'pdf') { if ($type === 'pdf') {