Blog
LnBlogObject
AttachmentContainer
use LnBlog\Tasks\AutoPublishTask; use LnBlog\Tasks\TaskManager; use LnBlog\Tasks\TaskRepository; use Psr\Log\LoggerInterface;
Blog

The "master" class which represents a weblog.  Nearly all functions are performed through this object. This is the object that handles user security.

Inherits

LnBlogObject

Events
OnInit

Fired when a blog object is created.

InitComplete

Fired after the constructor has run.

OnInsert

Run when a new blog is about to be created.

InsertComplete

Run after a new blog object has been saved.

OnUpdate

Run when a blog is about to be updated.

UpdateComplete

Run after a blog is successfully updated.

OnDelete

Run before a blog is deleted.

DeleteComplete

Run after a blog is deleted.

OnUpgrade

Run before the wrapper upgrade process.

UpgradeComplete

Run when the wrapper upgrade is finished.

OnEntryPreview

Run before populating entry template for preview.

OnArticlePreview

Fired before populating article template for preview.

OnEntryError

Fired before populating template when on an error.

OnArticelError

Fired before populating template when on an error.

RSS compatibility methods
Functions
isBlog
public function isBlog(
$blogfalse
)

Determines whether the object represents an existing blog.

Returns

True if the blog metadata exists, false otherwise.

writers
public function writers(
$listfalse
)

Set and return the list of users who can add posts to the blog.

Parameters
list

an arrays or comma-delimited stringof user names.

Returns

An array of user names.

readBlogData
private function readBlogData()

Read and write a simple text file with the blog metadata.  Format is key = data, each record is a single line, unrecognized keys are ignored.  This is for internal use only.

writeBlogData
private function writeBlogData()

Save the blog data to disk.  This is for internal use only.

Returns

False on failure, something else on success.

getDay
public function getDay(
$year,
$month,
$day
)

Get all the blog entries for a particular day.

Parameters
year

The year you want.

month

The month you want.

day

The day you want.

Returns

An array of BlogEntry objects posted on the given date, sorted in reverse chronological order by post time.

getDayCount
public function getDayCount(
$year,
$month,
$day
)

Get the number of posts made on a given day.

Parameters
year

The 4 digit year of the post.

month

The month of the post.

day

The day of the post.

Retruns

An integer representing how many posts were made that day.

getMonth
public function getMonth(
$year,
$month
)

Get a list of all entries for the specified month.  If you do not specify a year and month, then the routine will try to get it from the current directory and/or URL.

Parameters
year

The year you want.

month

The month you want.

Returns

An array of BlogEntry objects posted in the given month, sorted in reverse chronological order by post date.

getYear
public function getYear(
$yearfalse
)

Like getMonth, except gets entries for an entire year.

Parameters
year

Optional year to get.  If not given, the year will be auto-detected.

Returns

An array of BlogEntry objects posted in the given year, sorted in reverse chronological order by post date.

getYearList
public function getYearList()

Get a list of all years in the archive, sorted in reverse chronological order.

Returns

A two-dimensional array.  The first dimension has numeric indexes.  The second has two elements, indexed as "year" and "link", which hold the 4-digit year and a permalink to the archive of that year respectively.

getMonthList
public function getMonthList(
$yearfalse
)

Get a list of the months for the given year.  If no year is given, try to extract it from the current directory/URL.

Parameters
year

The year you want.

Returns

A two-dimensional array.  The first dimension is numerically indexed, with elements sorted in reverse chronological order.  The second dimension has three elements, indexed as "year", "month", and "link".  These hold, respectively, the year you specified, the 2-digit month, and a permalink to the archive for that month.

getRecentMonthList
public function getRecentMonthList(
$nummonths12
)

Get a list of recent months, starting from the current month and going backward.  This is essentially a wrapper around getMonthList.

Parameters
nummonths

Optional number of months to return.  The default is 12.  If set to zero or less, then all months will be retreived.

Returns

An array of the most recent months in the same format used by getMonthList.  The total length of the first dimension of the array should be nummonths long.

getURL
public function getURL(
$full_uritrue
)

Get the URL for the blog homepage.

Parameters
full_uri

Optional boolean for whether or not to return a full URI or a root-relative one.  Default is true.

Returns

A string holding the URI to the blog root directory.

uri
public function uri(
$type,
$params []
)

Get the URI of the designated resource.

Parameters
type

The type of URI to get, e.g. permalink, edit link, etc.

params

All other parameters after the first are interpreted as additional data for the URL query string.  The exact meaning of each parameter depends on the URL type.

Returns

A string with the permalink.

getRecent
public function getRecent(
$num_entriesfalse
)

Get the most recent entries across all months and years.

Parameters
num_entries

Optional number of entries to return.  The default is to use the <max_entries> property of the blog.  If -1 is passed, then all entries in the blog will be returned.

Returns

An array of BlogEntry objects.

getNextMax
public function getNextMax(
$num_entriesfalse
)

Convenience function to get "previous entries".  Returns a list of entries starting after the the end of the blog's <max_entires> property.

Parameters
num_entries

The optional number or entries to return.  The default is to use the blog's <max_entries> property.

Returns

An array of BlogEntry objects.

getEntries
public function getEntries(
$number -1,
$offset 0
)

Scan entries in reverse chronological order, starting at a given offset, and get a given number of them.

Parameters
number

Optional number of entries to return.  If set to a negative number, then returns all entries will be returned.  The default value is -1.

offset

Optional number of entries from the beginning of the list to skip.  The default is 0, i.e. start at the beginning.

Returns

An array of BlogEntry objects.

getEntriesByTag
public function getEntriesByTag(
$taglist,
$limit0,
$match_allfalse
)

Get a list of entries tagged with a given string.

Parameter
taglist

An array of tags to search for.

limit

Maximum number of entries to return.  The default is zero, which means return all matching entries.

match_all

Optional boolean that determines whether the entry must have every tag in taglist to match.  The default is false.

Returns

An array of entry objects, in reverse chronological order by post date.

getDrafts
public function getDrafts()

Gets all the current drafts for this blog.

Returns

An array of BlogEntry objects.

getArticles
public function getArticles(
$number null
)

Returns a list of all articles, in no particular order.

Parameters
number

Optional number of articles to return.  Default is all.

Returns

An array of Article objects.

getArticleList
public function getArticleList(
$number null,
$sticky_only true
)

Get a list of articles with title and permalink.

Parameters
number

Optional number of articles to return.  Default is all.

sticky_only

Optionally return only "sticky" articles.  Default is true.

Returns

A two-dimensional array.  The first is numerically indexed.  The second is two elements indexed as "title" and "link".  These represent the title of the article and the permalink to it respectively.

getEntryReplies
public function getEntryReplies()

Gets all the replies for all entries belonging to this blog, including all comments, trackbacks, and pingbacks.

Returns

An array of objects, including BlogComment, Trackback, and Pingback objects.  The sorting of this list is dependent on the data storage implementation for the blog.

getEntryComments
public function getEntryComments()

Like getEntryReplies, but only returns BlogComments.

getEntryTrackbacks
public function getEntryTrackbacks()

Like getEntryReplies, but only returns Trackbacks.

getEntryPingbacks
public function getEntryPingbacks()

Like getEntryReplies, but only returns Pingbacks.

getArticleReplies
public function getArticleReplies()

Like getEntryReplies, but returns the replies for all Articles, instead of for all BlogEntries.

getArticleComments
public function getArticleComments()

Like getArticleReplies, but only returns BlogComments.

getArticleTrackbacks
public function getArticleTrackbacks()

Like getArticleReplies, but only returns Trackbacks.

getArticleArticlePingbacks

Like getArticleReplies, but only returns Pingbacks.

getReplies
public function getReplies()

Like getEntryReplies and getArticleReplies, but combines both, returning an array of all replies for this blog.

getComments
public function getComments()

Like getReplies, but only for comments.

getTrackbacks
public function getTrackbacks()

Like getReplies, but only for trackbacks.

getPingbacks
public function getPingbacks()

Like getReplies, but only for pingbacks.

autoPingbackEnabled
public function autoPingbackEnabled()

Determine if pingbacks are on by default.

getAttachments
public function getAttachments()

Get a list of files attached to this blog.

Returns: Array of AttachedFile objects

addAttachment
public function addAttachment(
$path,
$name ''
)

Add an attached file to the blog.

Parameters
path

The local file path to the file to attach.

name

Optional name of the file.  Default is the existing name.

removeAttachment
public function removeAttachment(
$name
)

Remove a file that is attached to the blog.

Parameter
name

The name of the file to remove.

getManagedFiles
public function getManagedFiles()

Get a list of system files that are managed by the blog and are therefore excluded from uploads.

Returns: An array of file names.

exportVars
public function exportVars(
&$tpl
)

Export blog variables to a PHPTemplate class.  This is for internal use only.

Parameters
tpl

The PHPTemplate to populate.

upgradeWrappers
public function upgradeWrappers ()

This is an upgrade function that will create new config and wrapper scripts to upgrade a directory of blog data to the current version.  The data files will only be modified if required.  Copies of the old

Precondition

It is assumed that this function will only be run from the package installation directory.

Returns

True on success, false on failure.

fixDirectoryPermissions
public function fixDirectoryPermissions(
$start_dirfalse
)

A quick utility function to fix the borked permissions from not setting the correct umask when creating directories.  This resulted in directories that I couldn't alter via FTP.

Parameters
start_dir

The directory to fix.  Defaults to the blog root.

Returns

True on success, false otherwise.

insert
public function insert(
$pathfalse
)

Creates a new weblog.

Parameters
path

The path to the blog root.  Defaults to the current directory.

Returns

True on success, false otherwise.

update
public function update()

Modify an existing weblog.

Returns

True on success, false otherwise.

delete
public function delete(
$keep_history null
)

Removes an existing weblog.

Parameters
keep_history

If set to true, only delete the blog data file, making this a non-blog directory, rather than totally destroy the data.  If not set, defaults to KEEP_EDIT_HISTORY constant.

Returns

True on success, false on failure.

updateTagList
public function updateTagList(
$tags
)

Adds any new tags to the list of tags used in the current blog.

Parameters
tags

An array of strings holding the tags to be added.  Duplicates are removed.

Returns

True on success, false on failure.