mirror of
https://github.com/Karaka-Management/oms-OnlineResourceWatcher.git
synced 2026-02-17 00:18:41 +00:00
code fixes
This commit is contained in:
parent
094aa4ad30
commit
a72fb93533
|
|
@ -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,7 +334,7 @@ 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 ?? '');
|
||||||
|
|
||||||
|
$difference = 1;
|
||||||
|
if ($contentNew !== null && $contentOld !== null) {
|
||||||
// Calculate difference index
|
// Calculate difference index
|
||||||
$difference = \levenshtein($contentOld, $contentNew);
|
$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 ?? '',
|
||||||
' '
|
' '
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user