<?php
-namespace Oxbow\Http\Controllers;
+namespace BookStack\Http\Controllers;
use Activity;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
-use Oxbow\Http\Requests;
-use Oxbow\Repos\BookRepo;
-use Oxbow\Repos\ChapterRepo;
-use Oxbow\Repos\PageRepo;
+use BookStack\Http\Requests;
+use BookStack\Repos\BookRepo;
+use BookStack\Repos\ChapterRepo;
+use BookStack\Repos\PageRepo;
+use Views;
class BookController extends Controller
{
*/
public function index()
{
- $books = $this->bookRepo->getAll();
- return view('books/index', ['books' => $books]);
+ $books = $this->bookRepo->getAllPaginated(10);
+ $recents = $this->signedIn ? $this->bookRepo->getRecentlyViewed(10, 0) : false;
+ return view('books/index', ['books' => $books, 'recents' => $recents]);
}
/**
public function show($slug)
{
$book = $this->bookRepo->getBySlug($slug);
- return view('books/show', ['book' => $book, 'current' => $book]);
+ Views::add($book);
+ $bookChildren = $this->bookRepo->getChildren($book);
+ return view('books/show', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
}
/**
{
$this->checkPermission('book-update');
$book = $this->bookRepo->getBySlug($bookSlug);
+ $bookChildren = $this->bookRepo->getChildren($book);
$books = $this->bookRepo->getAll();
- return view('books/sort', ['book' => $book, 'current' => $book, 'books' => $books]);
+ return view('books/sort', ['book' => $book, 'current' => $book, 'books' => $books, 'bookChildren' => $bookChildren]);
}
public function getSortItem($bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
- return view('books/sort-box', ['book' => $book]);
+ $bookChildren = $this->bookRepo->getChildren($book);
+ return view('books/sort-box', ['book' => $book, 'bookChildren' => $bookChildren]);
}
/**
$isPage = $bookChild->type == 'page';
$bookId = $this->bookRepo->exists($bookChild->book) ? $bookChild->book : $defaultBookId;
$model = $isPage ? $this->pageRepo->getById($id) : $this->chapterRepo->getById($id);
- $isPage ? $this->pageRepo->setBookId($bookId, $model) : $this->chapterRepo->setBookId($bookId, $model);
+ $isPage ? $this->pageRepo->changeBook($bookId, $model) : $this->chapterRepo->changeBook($bookId, $model);
$model->priority = $index;
if ($isPage) {
$model->chapter_id = ($bookChild->parentChapter === false) ? 0 : $bookChild->parentChapter;