|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Coyote\Http\Controllers\Wiki; |
|
4
|
|
|
|
|
5
|
|
|
use Boduch\Grid\Source\EloquentSource; |
|
6
|
|
|
use Coyote\Http\Grids\Wiki\LogGrid; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
|
|
9
|
|
|
class LogController extends BaseController |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @param \Coyote\Wiki $wiki |
|
13
|
|
|
* @param Request $request |
|
14
|
|
|
* @return \Illuminate\View\View |
|
15
|
|
|
*/ |
|
16
|
|
|
public function index($wiki, Request $request) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->breadcrumb->push('Historia zmian', route('wiki.log', [$wiki->id])); |
|
19
|
|
|
|
|
20
|
|
|
$source = new EloquentSource( |
|
21
|
|
|
$this |
|
22
|
|
|
->wiki |
|
23
|
|
|
->getLogBuilder() |
|
24
|
|
|
->where('wiki_log.wiki_id', $wiki->wiki_id) |
|
25
|
|
|
->where('wiki_paths.path_id', $wiki->id) |
|
26
|
|
|
); |
|
27
|
|
|
|
|
28
|
|
|
/** @var LogGrid $grid */ |
|
29
|
|
|
$grid = $this |
|
30
|
|
|
->gridBuilder() |
|
31
|
|
|
->createGrid(LogGrid::class) |
|
32
|
|
|
->setSource($source) |
|
33
|
|
|
->setEnablePagination(false) |
|
34
|
|
|
->addComparisionButtons(); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
$diff = $this->diff($wiki, $request); |
|
37
|
|
|
|
|
38
|
|
|
return $this->view('wiki.log')->with(compact('grid', 'wiki', 'diff')); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param \Coyote\Wiki $wiki |
|
43
|
|
|
* @param Request $request |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
|
|
private function diff($wiki, Request $request) |
|
47
|
|
|
{ |
|
48
|
|
|
if (!$request->has('r1') || !$request->has('r2')) { |
|
49
|
|
|
return []; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return [ |
|
53
|
|
|
'before' => htmlspecialchars($wiki->logs->find($request->get('r1'), ['text'])->text), |
|
|
|
|
|
|
54
|
|
|
'after' => htmlspecialchars($wiki->logs->find($request->get('r2'), ['text'])->text) |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|