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,49 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Content;
|
||||
use App\Models\ContentHistory;
|
||||
|
||||
class History extends Controller
|
||||
{
|
||||
/**
|
||||
* @var ContentHistory
|
||||
*/
|
||||
private $history;
|
||||
|
||||
public function __construct(ContentHistory $history)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->history = $history;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function getOverview($id)
|
||||
{
|
||||
// test if given content id is static page and if exists
|
||||
$content = Content::findOrFail($id);
|
||||
|
||||
$history = $this->history->getStructuredHistoryOf($content);
|
||||
|
||||
return view('admin/history.overview', [
|
||||
'history' => $history,
|
||||
'page' => $content
|
||||
]);
|
||||
}
|
||||
|
||||
public function getDiff($revision, $id)
|
||||
{
|
||||
$change = $this->history->findOrFail($id);
|
||||
$diff = $this->history->getDiff($change);
|
||||
|
||||
return view('admin/history.diff', [
|
||||
'change' => $change,
|
||||
'columnName' => 'Page content',
|
||||
'diff' => $diff
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user