57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
namespace App\CMS\Handlers;
|
|
|
|
use App\CMS\Enumerations\ContentStatuses;
|
|
use App\CMS\Handlers\Contracts\HistoryHandler;
|
|
use App\CMS\Helpers\Differ;
|
|
|
|
class History implements HistoryHandler
|
|
{
|
|
public static function parseColumnName($column)
|
|
{
|
|
return trans('admin/history.column' . ucfirst($column));
|
|
}
|
|
|
|
public static function parseChangedValue($changeset)
|
|
{
|
|
switch ($changeset->column) {
|
|
case 'pageContent':
|
|
$route = route('history.diff', [
|
|
'revision' => $changeset->edit_batch,
|
|
'id' => $changeset->id
|
|
]);
|
|
|
|
return "(<a href='" . $route . "'>" . trans('admin/history.diff') . "</a>)";
|
|
break;
|
|
case 'metaDescription':
|
|
return Differ::htmlDiff($changeset->old_value, $changeset->new_value);
|
|
break;
|
|
case 'file':
|
|
if (!$changeset->old_value) {
|
|
// old value is null -> new file was uploaded
|
|
return trans('admin/history.uploadedFile', ['file' => $changeset->new_value]);
|
|
} else {
|
|
return trans('admin/history.deletedFile', ['file' => $changeset->old_value]);
|
|
}
|
|
|
|
break;
|
|
case 'status':
|
|
$statuses = ContentStatuses::getWithTranslations();
|
|
|
|
return trans('admin/history.changedFromTo', [
|
|
'from' => $statuses[$changeset->old_value],
|
|
'to' => $statuses[$changeset->new_value]
|
|
]);
|
|
break;
|
|
case 'is_homepage':
|
|
return trans('admin/history.setupAsHomepage');
|
|
break;
|
|
default:
|
|
return trans('admin/history.changedFromTo', [
|
|
'from' => is_null($changeset->old_value) ? trans('admin/history.emptyValue') : $changeset->old_value,
|
|
'to' => is_null($changeset->new_value) ? trans('admin/history.emptyValue') : $changeset->new_value,
|
|
]);
|
|
break;
|
|
}
|
|
}
|
|
} |