PHP Class Airship\Cabin\Bridge\Blueprint\Blog

Blog posts, categories, series, tags.
Inheritance: extends BlueprintGear, use trait Common, use trait Orderable, use trait Slug, use trait Airship\Engine\Bolt\Cache
Show file Open project: paragonie/airship Class Usage Examples

Protected Properties

Property Type Description
$cabin Cabin for this blog post (used as a default parameter)

Public Methods

Method Description
categoryDescendsFrom ( integer $newParent, integer $categoryId ) : boolean Sanity check; don't allow a category to belong to one of its children.
createCategory ( array $post ) : boolean Create a new category
createPost ( array $post, boolean $publish = false ) : boolean Create (and, optionally, publish) a new blog post.
createSeries ( array $post ) : boolean Inserts a new series, and the subsequent items, in the database
createTag ( array $post ) : boolean Create a new tag
deleteCategory ( integer $categoryID, integer $moveChildrenTo ) : boolean Delete a category and move all related content
deleteComment ( integer $commentId ) : boolean Delete this comment and all of its revision history.
deletePost ( array $formData, array $blogPost = [] ) : boolean Delete a blog post
deleteSeries ( integer $seriesId ) : boolean Permanently remove a blog post series.
editTag ( integer $tagId, array $post ) : boolean Rename a tag
getAllSeries ( integer $offset, integer $limit ) : array Get all of the series (paginated)
getAllSeriesParents ( array $seriesIds, integer $depth ) : array Get all of the series that this series belongs to, recursively.
getBlogPostById ( integer $postId ) : array Get information about a blog post
getBlogPostLatestVersion ( integer $postId ) : array Get the latest version of a blog post
getBlogPostVersionByUniqueId ( string $uniqueID ) : array Get a specific blog post version, given a unique ID
getBlogPostVersions ( integer $postId ) : array
getCategoryInfo ( integer $categoryId ) : array Get a category
getCategoryParents ( integer $categoryId, integer $depth ) : array Get all of a category's parents
getCategoryTree ( integer $parent = null, string $col = 'children', array $seen = [], integer $depth ) : array Get a full category tree, recursively, from a given parent
getCommentById ( integer $commentId, boolean $includeReplyTo = true ) : array Get a blog comment
getNextVersionUniqueId ( integer $postId, integer $currentVersionId ) : string Get the next version's unique ID
getPrevVersionUniqueId ( integer $postId, integer $currentVersionId ) : string Get the previous version's unique ID
getSeries ( integer $seriesId ) : array Get a single series
getSeriesForAuthor ( integer $authorId, array $exclude = [] ) : array Get all of the series for a particular author
getSeriesForUser ( integer $userId, integer $offset, integer $limit ) : array Get all of the series for all of the authors the user owns
getSeriesItems ( integer $seriesId ) : array Get a single series
getSeriesTree ( integer $current = null, string $col = 'children', array $encountered = [], integer $depth ) : array Get a full series tree, recursively, from a given parent
getTagInfo ( integer $tagId ) : array Get data on a specific tag
getTags ( ) : array Get all of the tags in the database
getTagsForPost ( integer $postId ) : array Get a list of all selected blog posts
hideComment ( integer $commentId ) : boolean Make a comment invisible on blog posts.
listComments ( integer $offset, integer $limit = 20 ) : array List comments
listPosts ( boolean $showAll = false, integer $offset, integer $limit = 20 ) : array Get the most recent posts
listPostsForAuthor ( integer $authorId, array $exclude = [] ) : array Get all of the series for a particular author
listTags ( integer $offset, integer $limit, string $sort = 'name', boolean $desc = false ) : array List tags (paginated, sortable).
numComments ( mixed $published = null ) : integer Count the number of posts. trinary: NULL -> all posts TRUE -> all published posts FALSE -> all unpublished posts
numItemsInSeries ( integer $seriesId ) : integer Get the number of items in a given series.
numPosts ( mixed $published = null ) : integer Count the number of posts. trinary: NULL -> all posts TRUE -> all published posts FALSE -> all unpublished posts
numSeries ( ) : integer Count the number of series in the database
numSeriesForUser ( integer $userId ) : integer Count the number of series for a user
numTags ( ) : integer Count the number of tags
publishComment ( integer $commentId ) : boolean Publish an unapproved blog comment.
updateCategory ( integer $id, array $post ) : boolean Update a blog category
updateCategorySlug ( integer $id, array $post ) : boolean
updatePost ( array $post, array $old, boolean $publish = false ) : boolean Update a blog post
updateSeries ( integer $seriesId, array $oldItems, array $post ) : boolean Insert/delete/rearrange the contents of a series.

Protected Methods

Method Description
makeBlogPostSlug ( string $title, string $year = '', string $month = '' ) : string Make a generic slug for most tables

Method Details

categoryDescendsFrom() public method

Returns TRUE if this check is violated.
public categoryDescendsFrom ( integer $newParent, integer $categoryId ) : boolean
$newParent integer
$categoryId integer
return boolean

createCategory() public method

Create a new category
public createCategory ( array $post ) : boolean
$post array
return boolean

createPost() public method

Create (and, optionally, publish) a new blog post.
public createPost ( array $post, boolean $publish = false ) : boolean
$post array
$publish boolean
return boolean

createSeries() public method

Inserts a new series, and the subsequent items, in the database
public createSeries ( array $post ) : boolean
$post array
return boolean

createTag() public method

Create a new tag
public createTag ( array $post ) : boolean
$post array
return boolean

deleteCategory() public method

Delete a category and move all related content
public deleteCategory ( integer $categoryID, integer $moveChildrenTo ) : boolean
$categoryID integer
$moveChildrenTo integer
return boolean

deleteComment() public method

Delete this comment and all of its revision history.
public deleteComment ( integer $commentId ) : boolean
$commentId integer
return boolean

deletePost() public method

Delete a blog post
public deletePost ( array $formData, array $blogPost = [] ) : boolean
$formData array
$blogPost array
return boolean

deleteSeries() public method

Permanently remove a blog post series.
public deleteSeries ( integer $seriesId ) : boolean
$seriesId integer
return boolean

editTag() public method

Rename a tag
public editTag ( integer $tagId, array $post ) : boolean
$tagId integer
$post array
return boolean

getAllSeries() public method

Get all of the series (paginated)
public getAllSeries ( integer $offset, integer $limit ) : array
$offset integer
$limit integer
return array

getAllSeriesParents() public method

This is mostly used for generating the appropriate "prev/next" links on the View Blog Post page.
public getAllSeriesParents ( array $seriesIds, integer $depth ) : array
$seriesIds array
$depth integer
return array

getBlogPostById() public method

Get information about a blog post
public getBlogPostById ( integer $postId ) : array
$postId integer
return array

getBlogPostLatestVersion() public method

Get the latest version of a blog post
public getBlogPostLatestVersion ( integer $postId ) : array
$postId integer
return array

getBlogPostVersionByUniqueId() public method

Get a specific blog post version, given a unique ID
public getBlogPostVersionByUniqueId ( string $uniqueID ) : array
$uniqueID string
return array

getBlogPostVersions() public method

public getBlogPostVersions ( integer $postId ) : array
$postId integer
return array

getCategoryInfo() public method

Get a category
public getCategoryInfo ( integer $categoryId ) : array
$categoryId integer
return array

getCategoryParents() public method

Get all of a category's parents
public getCategoryParents ( integer $categoryId, integer $depth ) : array
$categoryId integer
$depth integer
return array

getCategoryTree() public method

Get a full category tree, recursively, from a given parent
public getCategoryTree ( integer $parent = null, string $col = 'children', array $seen = [], integer $depth ) : array
$parent integer
$col string The "children" column name
$seen array
$depth integer How deep are we?
return array

getCommentById() public method

Get a blog comment
public getCommentById ( integer $commentId, boolean $includeReplyTo = true ) : array
$commentId integer
$includeReplyTo boolean Also grab the parent comment?
return array

getNextVersionUniqueId() public method

Get the next version's unique ID
public getNextVersionUniqueId ( integer $postId, integer $currentVersionId ) : string
$postId integer
$currentVersionId integer
return string

getPrevVersionUniqueId() public method

Get the previous version's unique ID
public getPrevVersionUniqueId ( integer $postId, integer $currentVersionId ) : string
$postId integer
$currentVersionId integer
return string

getSeries() public method

Get a single series
public getSeries ( integer $seriesId ) : array
$seriesId integer
return array

getSeriesForAuthor() public method

Get all of the series for a particular author
public getSeriesForAuthor ( integer $authorId, array $exclude = [] ) : array
$authorId integer
$exclude array Series IDs to exclude
return array

getSeriesForUser() public method

Get all of the series for all of the authors the user owns
public getSeriesForUser ( integer $userId, integer $offset, integer $limit ) : array
$userId integer
$offset integer
$limit integer
return array

getSeriesItems() public method

Get a single series
public getSeriesItems ( integer $seriesId ) : array
$seriesId integer
return array

getSeriesTree() public method

Get a full series tree, recursively, from a given parent
public getSeriesTree ( integer $current = null, string $col = 'children', array $encountered = [], integer $depth ) : array
$current integer
$col string The "children" column name
$encountered array Which IDs have we seen before?
$depth integer How deep are we?
return array

getTagInfo() public method

Get data on a specific tag
public getTagInfo ( integer $tagId ) : array
$tagId integer
return array

getTags() public method

Get all of the tags in the database
public getTags ( ) : array
return array

getTagsForPost() public method

Get a list of all selected blog posts
public getTagsForPost ( integer $postId ) : array
$postId integer
return array

hideComment() public method

Make a comment invisible on blog posts.
public hideComment ( integer $commentId ) : boolean
$commentId integer
return boolean

listComments() public method

List comments
public listComments ( integer $offset, integer $limit = 20 ) : array
$offset integer
$limit integer
return array

listPosts() public method

Get the most recent posts
public listPosts ( boolean $showAll = false, integer $offset, integer $limit = 20 ) : array
$showAll boolean
$offset integer
$limit integer
return array

listPostsForAuthor() public method

Get all of the series for a particular author
public listPostsForAuthor ( integer $authorId, array $exclude = [] ) : array
$authorId integer
$exclude array Series IDs to exclude
return array

listTags() public method

List tags (paginated, sortable).
public listTags ( integer $offset, integer $limit, string $sort = 'name', boolean $desc = false ) : array
$offset integer
$limit integer
$sort string
$desc boolean
return array

makeBlogPostSlug() protected method

Make a generic slug for most tables
protected makeBlogPostSlug ( string $title, string $year = '', string $month = '' ) : string
$title string What are we basing the URL off of?
$year string
$month string
return string

numComments() public method

Count the number of posts. trinary: NULL -> all posts TRUE -> all published posts FALSE -> all unpublished posts
public numComments ( mixed $published = null ) : integer
$published mixed
return integer

numItemsInSeries() public method

Get the number of items in a given series.
public numItemsInSeries ( integer $seriesId ) : integer
$seriesId integer
return integer

numPosts() public method

Count the number of posts. trinary: NULL -> all posts TRUE -> all published posts FALSE -> all unpublished posts
public numPosts ( mixed $published = null ) : integer
$published mixed
return integer

numSeries() public method

Count the number of series in the database
public numSeries ( ) : integer
return integer

numSeriesForUser() public method

Count the number of series for a user
public numSeriesForUser ( integer $userId ) : integer
$userId integer
return integer

numTags() public method

Count the number of tags
public numTags ( ) : integer
return integer

publishComment() public method

Publish an unapproved blog comment.
public publishComment ( integer $commentId ) : boolean
$commentId integer
return boolean

updateCategory() public method

Update a blog category
public updateCategory ( integer $id, array $post ) : boolean
$id integer
$post array
return boolean

updateCategorySlug() public method

public updateCategorySlug ( integer $id, array $post ) : boolean
$id integer
$post array
return boolean

updatePost() public method

Update a blog post
public updatePost ( array $post, array $old, boolean $publish = false ) : boolean
$post array
$old array
$publish boolean
return boolean

updateSeries() public method

Insert/delete/rearrange the contents of a series.
public updateSeries ( integer $seriesId, array $oldItems, array $post ) : boolean
$seriesId integer
$oldItems array
$post array
return boolean

Property Details

$cabin protected property

Cabin for this blog post (used as a default parameter)
protected $cabin