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:
Michal Kváček
2016-02-05 16:06:13 +01:00
parent 0216d923d4
commit 620a5545d8
12 changed files with 370 additions and 18 deletions
+45
View File
@@ -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;
}
}
}