PHP Class BookStack\Repos\PageRepo

Inheritance: extends EntityRepo
Show file Open project: ssddanbrown/bookstack Class Usage Examples

Protected Properties

Property Type Description
$pageRevision
$tagRepo

Public Methods

Method Description
__construct ( PageRevision $pageRevision, TagRepo $tagRepo ) PageRepo constructor.
changeBook ( integer $bookId, Page $page ) : Page Changes the related book for the specified page.
changePageParent ( Page $page, Entity $parent ) Change the page's parent to the given entity.
countBySlug ( $slug, $bookId ) : mixed Count the pages with a particular slug within a book.
destroy ( Page $page ) Destroy a given page along with its dependencies.
doesSlugExist ( $slug, $bookId, boolean | false $currentId = false ) : boolean Checks if a slug exists within a book already.
findPageUsingOldSlug ( $pageSlug, $bookSlug ) : null | Page Search through page revisions and retrieve the last page in the current book that has a slug equal to the one given.
findSuitableSlug ( string $name, integer $bookId, boolean | false $currentId = false ) : string Gets a suitable slug for the resource
getById ( $id, boolean $allowDrafts = false ) : Page Get a page via a specific ID.
getBySearch ( string $term, array $whereTerms = [], integer $count = 20, array $paginationAppends = [] ) : mixed Gets pages by a search term.
getBySlug ( $slug, $bookId ) : Page Get a page identified by the given slug.
getDraftPage ( Book $book, Chapter | boolean $chapter = false ) : static Get a new draft page instance.
getPageEditingActiveMessage ( Page $page, null $minRange = null ) : string Get a notification message concerning the editing activity on a particular page.
getPageNav ( Page $page ) : array Parse te headers on the page to get a navigation menu
getRecentlyCreatedPaginated ( $count = 20 ) : mixed Get the latest pages added to the system.
getRecentlyUpdatedPaginated ( $count = 20 ) : mixed Get the latest pages added to the system.
getRevisionById ( $id ) : PageRevision Gets a single revision via it's id.
getUserPageDraft ( Page $page, $userId ) : mixed Get the latest updated draft revision for a particular page and user.
getUserPageDraftMessage ( PageRevision $draft ) : string Get the notification message that informs the user that they are editing a draft page.
hasUserGotPageDraft ( Page $page, $userId ) : boolean Checks whether a user has a draft version of a particular page or not.
isPageEditingActive ( Page $page, null $minRange = null ) : boolean Check if a page is being actively editing.
newFromInput ( $input ) : Page Get a new Page instance from the given input.
publishDraft ( Page $draftPage, array $input ) : Page Publish a draft page to make it a normal page.
restoreRevision ( Page $page, Book $book, integer $revisionId ) : Page Restores a revision's content back into a page.
saveRevision ( Page $page, null | string $summary = null ) Saves a page revision into the system.
saveUpdateDraft ( Page $page, array $data = [] ) : PageRevision Save a page update draft.
searchForImage ( $imageString ) : mixed Search for image usage.
updateDraftPage ( Page $page, array $data = [] ) : Page Update a draft page.
updatePage ( Page $page, integer $book_id, string $input ) : Page Updates a page with any fillable data and saves it into the database.

Protected Methods

Method Description
formatHtml ( string $htmlText ) : string Formats a page's html to be tagged correctly within the system.

Private Methods

Method Description
activePageEditingQuery ( Page $page, null $minRange = null ) : mixed A query to check for active update drafts on a particular page.
pageQuery ( boolean $allowDrafts = false ) : mixed Base query for getting pages, Takes restrictions into account.
userUpdateDraftsQuery ( Page $page, $userId ) : mixed The base query for getting user update drafts.

Method Details

__construct() public method

PageRepo constructor.
public __construct ( PageRevision $pageRevision, TagRepo $tagRepo )
$pageRevision BookStack\PageRevision
$tagRepo TagRepo

changeBook() public method

Changes the book id of any relations to the page that store the book id.
public changeBook ( integer $bookId, Page $page ) : Page
$bookId integer
$page BookStack\Page
return BookStack\Page

changePageParent() public method

Change the page's parent to the given entity.
public changePageParent ( Page $page, Entity $parent )
$page BookStack\Page
$parent BookStack\Entity

countBySlug() public method

Count the pages with a particular slug within a book.
public countBySlug ( $slug, $bookId ) : mixed
$slug
$bookId
return mixed

destroy() public method

Destroy a given page along with its dependencies.
public destroy ( Page $page )
$page BookStack\Page

doesSlugExist() public method

Checks if a slug exists within a book already.
public doesSlugExist ( $slug, $bookId, boolean | false $currentId = false ) : boolean
$slug
$bookId
$currentId boolean | false
return boolean

findPageUsingOldSlug() public method

Search through page revisions and retrieve the last page in the current book that has a slug equal to the one given.
public findPageUsingOldSlug ( $pageSlug, $bookSlug ) : null | Page
$pageSlug
$bookSlug
return null | BookStack\Page | Page

findSuitableSlug() public method

Gets a suitable slug for the resource
public findSuitableSlug ( string $name, integer $bookId, boolean | false $currentId = false ) : string
$name string
$bookId integer
$currentId boolean | false
return string

formatHtml() protected method

Formats a page's html to be tagged correctly within the system.
protected formatHtml ( string $htmlText ) : string
$htmlText string
return string

getById() public method

Get a page via a specific ID.
public getById ( $id, boolean $allowDrafts = false ) : Page
$id
$allowDrafts boolean
return BookStack\Page

getBySearch() public method

Highlights page content for showing in results.
public getBySearch ( string $term, array $whereTerms = [], integer $count = 20, array $paginationAppends = [] ) : mixed
$term string
$whereTerms array
$count integer
$paginationAppends array
return mixed

getBySlug() public method

Get a page identified by the given slug.
public getBySlug ( $slug, $bookId ) : Page
$slug
$bookId
return BookStack\Page

getDraftPage() public method

Get a new draft page instance.
public getDraftPage ( Book $book, Chapter | boolean $chapter = false ) : static
$book BookStack\Book
$chapter BookStack\Chapter | boolean
return static

getPageEditingActiveMessage() public method

Get a notification message concerning the editing activity on a particular page.
public getPageEditingActiveMessage ( Page $page, null $minRange = null ) : string
$page BookStack\Page
$minRange null
return string

getPageNav() public method

Parse te headers on the page to get a navigation menu
public getPageNav ( Page $page ) : array
$page BookStack\Page
return array

getRecentlyCreatedPaginated() public method

Get the latest pages added to the system.
public getRecentlyCreatedPaginated ( $count = 20 ) : mixed
$count
return mixed

getRecentlyUpdatedPaginated() public method

Get the latest pages added to the system.
public getRecentlyUpdatedPaginated ( $count = 20 ) : mixed
$count
return mixed

getRevisionById() public method

Gets a single revision via it's id.
public getRevisionById ( $id ) : PageRevision
$id
return BookStack\PageRevision

getUserPageDraft() public method

Get the latest updated draft revision for a particular page and user.
public getUserPageDraft ( Page $page, $userId ) : mixed
$page BookStack\Page
$userId
return mixed

getUserPageDraftMessage() public method

Get the notification message that informs the user that they are editing a draft page.
public getUserPageDraftMessage ( PageRevision $draft ) : string
$draft BookStack\PageRevision
return string

hasUserGotPageDraft() public method

Checks whether a user has a draft version of a particular page or not.
public hasUserGotPageDraft ( Page $page, $userId ) : boolean
$page BookStack\Page
$userId
return boolean

isPageEditingActive() public method

Checks for edits since last page updated. Passing in a minuted range will check for edits within the last x minutes.
public isPageEditingActive ( Page $page, null $minRange = null ) : boolean
$page BookStack\Page
$minRange null
return boolean

newFromInput() public method

Get a new Page instance from the given input.
public newFromInput ( $input ) : Page
$input
return BookStack\Page

publishDraft() public method

Sets the slug and updates the content.
public publishDraft ( Page $draftPage, array $input ) : Page
$draftPage BookStack\Page
$input array
return BookStack\Page

restoreRevision() public method

Restores a revision's content back into a page.
public restoreRevision ( Page $page, Book $book, integer $revisionId ) : Page
$page BookStack\Page
$book BookStack\Book
$revisionId integer
return BookStack\Page

saveRevision() public method

Saves a page revision into the system.
public saveRevision ( Page $page, null | string $summary = null )
$page BookStack\Page
$summary null | string

saveUpdateDraft() public method

Save a page update draft.
public saveUpdateDraft ( Page $page, array $data = [] ) : PageRevision
$page BookStack\Page
$data array
return BookStack\PageRevision

searchForImage() public method

Search for image usage.
public searchForImage ( $imageString ) : mixed
$imageString
return mixed

updateDraftPage() public method

Update a draft page.
public updateDraftPage ( Page $page, array $data = [] ) : Page
$page BookStack\Page
$data array
return BookStack\Page

updatePage() public method

Updates a page with any fillable data and saves it into the database.
public updatePage ( Page $page, integer $book_id, string $input ) : Page
$page BookStack\Page
$book_id integer
$input string
return BookStack\Page

Property Details

$pageRevision protected property

protected $pageRevision

$tagRepo protected property

protected $tagRepo