use Activity;
use BookStack\Auth\UserRepo;
use BookStack\Entities\Book;
+use BookStack\Entities\EntityContextManager;
use BookStack\Entities\Repos\EntityRepo;
use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
protected $entityRepo;
protected $userRepo;
protected $exportService;
+ protected $entityContextManager;
/**
* BookController constructor.
* @param EntityRepo $entityRepo
- * @param \BookStack\Auth\UserRepo $userRepo
- * @param \BookStack\Entities\ExportService $exportService
+ * @param UserRepo $userRepo
+ * @param ExportService $exportService
+ * @param EntityContextManager $entityContextManager
*/
- public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportService $exportService)
- {
+ public function __construct(
+ EntityRepo $entityRepo,
+ UserRepo $userRepo,
+ ExportService $exportService,
+ EntityContextManager $entityContextManager
+ ) {
$this->entityRepo = $entityRepo;
$this->userRepo = $userRepo;
$this->exportService = $exportService;
+ $this->entityContextManager = $entityContextManager;
parent::__construct();
}
$popular = $this->entityRepo->getPopular('book', 4, 0);
$new = $this->entityRepo->getRecentlyCreated('book', 4, 0);
+ $this->entityContextManager->clearShelfContext();
+
$this->setPageTitle(trans('entities.books'));
return view('books.index', [
'books' => $books,
/**
* Display the specified book.
* @param $slug
+ * @param Request $request
* @return Response
+ * @throws \BookStack\Exceptions\NotFoundException
*/
- public function show($slug)
+ public function show($slug, Request $request)
{
$book = $this->entityRepo->getBySlug('book', $slug);
$this->checkOwnablePermission('book-view', $book);
+
$bookChildren = $this->entityRepo->getBookChildren($book);
+
Views::add($book);
+ if ($request->has('shelf')) {
+ $this->entityContextManager->setShelfContext(intval($request->get('shelf')));
+ }
+
$this->setPageTitle($book->getShortName());
return view('books.show', [
'book' => $book,