FEATURE #1373: add history of content
This commit contains only core funcionality of displaying history. Module settings must be implemented in each module.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace App\Handlers;
|
||||
|
||||
use App\Enumerations\ContentStatuses;
|
||||
use App\Handlers\Contracts\HistoryHandler;
|
||||
use App\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 'status':
|
||||
$statuses = ContentStatuses::getWithTranslations();
|
||||
|
||||
return trans('admin/history.changedFromTo', [
|
||||
'from' => $statuses[$changeset->old_value],
|
||||
'to' => $statuses[$changeset->new_value]
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
return trans('admin/history.changedFromTo', [
|
||||
'from' => $changeset->old_value,
|
||||
'to' => $changeset->new_value
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user