use Activity;
use BookStack\Auth\UserRepo;
use BookStack\Entities\Bookshelf;
+use BookStack\Entities\EntityContextManager;
use BookStack\Entities\Repos\EntityRepo;
-use BookStack\Entities\ExportService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
protected $entityRepo;
protected $userRepo;
- protected $exportService;
+ protected $entityContextManager;
/**
* BookController constructor.
- * @param \BookStack\Entities\Repos\EntityRepo $entityRepo
+ * @param EntityRepo $entityRepo
* @param UserRepo $userRepo
- * @param \BookStack\Entities\ExportService $exportService
+ * @param EntityContextManager $entityContextManager
*/
- public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, ExportService $exportService)
+ public function __construct(EntityRepo $entityRepo, UserRepo $userRepo, EntityContextManager $entityContextManager)
{
$this->entityRepo = $entityRepo;
$this->userRepo = $userRepo;
- $this->exportService = $exportService;
+ $this->entityContextManager = $entityContextManager;
parent::__construct();
}
*/
public function index()
{
-
$view = setting()->getUser($this->currentUser, 'bookshelves_view_type', config('app.views.bookshelves', 'grid'));
-
$sort = setting()->getUser($this->currentUser, 'bookshelves_sort', 'name');
$order = setting()->getUser($this->currentUser, 'bookshelves_sort_order', 'asc');
$sortOptions = [
];
$shelves = $this->entityRepo->getAllPaginated('bookshelf', 18, $sort, $order);
+ foreach ($shelves as $shelf) {
+ $shelf->books = $this->entityRepo->getBookshelfChildren($shelf);
+ }
+
$recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('bookshelf', 4, 0) : false;
$popular = $this->entityRepo->getPopular('bookshelf', 4, 0);
$new = $this->entityRepo->getRecentlyCreated('bookshelf', 4, 0);
-
+ $this->entityContextManager->clearShelfContext();
$this->setPageTitle(trans('entities.shelves'));
return view('shelves.index', [
'shelves' => $shelves,
*/
public function show(string $slug)
{
- $bookshelf = $this->entityRepo->getBySlug('bookshelf', $slug); /** @var $bookshelf Bookshelf */
+ /** @var Bookshelf $bookshelf */
+ $bookshelf = $this->entityRepo->getBySlug('bookshelf', $slug);
$this->checkOwnablePermission('book-view', $bookshelf);
$books = $this->entityRepo->getBookshelfChildren($bookshelf);
Views::add($bookshelf);
+ $this->entityContextManager->setShelfContext($bookshelf->id);
$this->setPageTitle($bookshelf->getShortName());
return view('shelves.show', [