mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-25 11:45:58 +00:00
![Dan Brown](/assets/img/avatar_default.png)
Since they no longer needed to run the parent contructor since the parent constructor was no longer needed.
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Http\Controllers;
|
|
|
|
use BookStack\Entities\Repos\PageRepo;
|
|
use BookStack\Exceptions\NotFoundException;
|
|
use Illuminate\Http\Request;
|
|
|
|
class PageTemplateController extends Controller
|
|
{
|
|
protected $pageRepo;
|
|
|
|
/**
|
|
* PageTemplateController constructor
|
|
*/
|
|
public function __construct(PageRepo $pageRepo)
|
|
{
|
|
$this->pageRepo = $pageRepo;
|
|
}
|
|
|
|
/**
|
|
* Fetch a list of templates from the system.
|
|
*/
|
|
public function list(Request $request)
|
|
{
|
|
$page = $request->get('page', 1);
|
|
$search = $request->get('search', '');
|
|
$templates = $this->pageRepo->getTemplates(10, $page, $search);
|
|
|
|
if ($search) {
|
|
$templates->appends(['search' => $search]);
|
|
}
|
|
|
|
return view('pages.template-manager-list', [
|
|
'templates' => $templates
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the content of a template.
|
|
* @throws NotFoundException
|
|
*/
|
|
public function get(int $templateId)
|
|
{
|
|
$page = $this->pageRepo->getById($templateId);
|
|
|
|
if (!$page->template) {
|
|
throw new NotFoundException();
|
|
}
|
|
|
|
return response()->json([
|
|
'html' => $page->html,
|
|
'markdown' => $page->markdown,
|
|
]);
|
|
}
|
|
}
|