BlogEntry
Entry
AttachmentContainer
BlogEntry

Represents an entry in the weblog.

Inherits

LnBlogObject, Entry

Events
OnInit

Fired when object is first created.

InitComplete

Fired at end of constructor.

OnInsert

Fired before object is saved to persistent storage.

InsertComplete

Fired after object has finished saving.

OnDelete

Fired before object is deleted.

DeleteComplete

Fired after object is deleted.

OnUpdate

Fired before changes are saved to persistent storage.

UpdateComplete

Fired after changes to object are saved.

OnOutput

Fired before output is generated.

OutputComplete

Fired after output has finished being generated.

POSTRetrieved

Fired after data has been retrieved from an HTTP POST.

Functions
getParent
public function getParent()

Get a copy of the parent of this objcet, i.e. the blog to which it belongs.

Returns

A Blog object.

entryID
public function entryID()

Gets an identifier for the current entry.

Returns

For file-based storage, string containing the last part of the path.  Normally, this is in the form ##/##/##_#### or ##_#### for drafts

globalID
public function globalID()

A unique ID for use with blogging APIs.  Note that this ID embedds the parent blog's ID, whereas the entryID method provides an ID within the current blog.

Returns

A string with the unique ID.

getEnclosure
public function getEnclosure()

Gets the URL, file size, and media type of the file set as the enclosure for this entry, it if exists.  The file is checkedy by converting the URL into a local path using the same rules as entry URL absolutizaiton, or simply doing a URL to localpath conversion.

Returns

If the enclosure property is set and the file is found, returns an array with elements "url", "length", and "type".  If the file is not found, then checks if the enclosure matches the expected content or an enclosure tag in an RSS feed.  If so, extracts the data into an array.  Otherwise Otherwise, returns false.

getPath
public function getPath(
$curr_ts,
$just_namefalse,
$long_formatfalse
)

Returns a path to use for the entry.  This is only applicable for file-based storage and is for internal use only.

Parameters
curr_ts

The timestamp for this entry.

just_name

Optional boolean determining whether to return a full path or just a file name.  Default is false.

long_format

Optional boolean for whether to use a long or regular date format.  Defaults to false.

Returns

A string with the path to use for this entry.

setSticky
public function setSticky(
$showtrue
)

Set whether or not an article should be considered "featured".  Articles not set sticky should be considered archival and not shown on things like front-page article lists.

Parameters
show

Optional boolean parameter to turn stickiness on or off.  Default is true (stickiness on).

Returns

True on success, false on failure.

isSticky
public function isSticky(
$pathfalse
)

Determines if the article is set as sticky.

Parameters
path

Optional unique ID for the article.

Returns

True if the article is sticky, false otherwise.

readSticky
public function readSticky(
$path null
)

Get the title and permalink without retreiving the entire article.

Parameters
path

The unique ID for the article.  Defaults to current ID if entry exists.

Returns

A two-element array, with "link" and "title" for the permalink and subject of the article.

isEntry
public function isEntry (
$pathfalse
)

Determine if the object is a blog entry or not.

Parameter
path

Optional path to the entry.  If not set, use the current object.

Return

True if the object is an existing entry, false otherwise.

isDraft
public function isDraft(
$pathfalse
)

Checks if the given entry is saved as a draft, as opposed to a published blog entry.

Returns

True if the entry is a draft, false otherwise.

isPublished
public function isPublished(
$pathfalse
)

Determine if the entry has been published.

Parameters
path

The path to the entry.

Returns

Whether or not the entry exists and is not a draft.

localpath
public function localpath()

Get the path to this entry's directory on the local filesystem.  Note that this is specific to file-based storage and so should only be c called internally.

Returns

A string representing a path to the object or false on failure.

permalink
public function permalink()

Get the permalink to the object.

Returns

A string containing the full URI to this entry.

commentlink

Get the permalink to the object.

getAutoPublishDate
public function getAutoPublishDate()

Get the auto-publish date.

Returns

The date string when publication will happen or empty string.

calcPrettyPermalink
public function calcPrettyPermalink()

Calculates a file name for a "pretty" permalink wrapper script.

Returns

The string to be used for the file name.

calcLegacyPermalink
public function calcLegacyPermalink(
$use_broken_regexfalse
)

Calculates a file name for a "pretty" permalink wrapper script using the old, ugly permalink computation.

Parameters
use_broken_regex

Optional parameter to calculate the URI based on the ugly regex used in LnBlog < 0.7.  Defaults to false.

Returns

The string to be used for the file name.

makePrettyPermalink
public function makePrettyPermalink()

Creates a wrapper script that makes a "pretty" permalink to the entry directory based on the subject text of the entry.

Returns

True on success, false on failure.

getPostData
public function getPostData()

Extract data from an HTTP POST and insert it into the object.  The data fields in the POST are described below.

Fields
subject

The subject of the entry, in plain text.

short_path

The "short path" to access an article.

abstract

An abstract of the entry, with markup.

tags

A comma-delimited list of free-form tags.

body

The entry body, with markup.

comments

Boolean representing whether new comments can be posted.

input_mode

Tristate variable representing the type of markup used.  Valid values are defined by the constants MARKUP_NONE, MARKUP_BBCODE, and MARKUP_HTML.

exportVars
public function exportVars(
&$tmp,
$show_edit_controlsfalse
)

Sets template variables with the entry data.

Parameters
tmp

The template we wish to populate.

get
public function get(
BasePages $web_page,
$show_edit_controlsfalse
)

Get the HTML to use to display the entry summary.

Parameters
show_edit_controls
BasePages$

Optional boolean determining if the edit, delete, etc. links should be displayed.  Defaults to false.

Returns

A string containing the markup.

getFull
public function getFull(
$show_edit_controlsfalse
)

Get the HTML to use to display the full entry page.

Parameters
show_edit_controls

Optional boolean determining if the edit, delete, etc. links should be displayed.  Defaults to false.

Returns

A string containing the markup.

getReplyCount
public function getReplyCount(
$params
)

Get the number of replies of a particular type.

Parameters
parms

An associative array of various parameters.  The valid array keys are "path", which is the directory to scan, "ext", which is the file extension of the data files, and "match_re", which is a regular expression matching the names of the data files minus the extension (default is /[\w\d]+/)).  Note that "path" and "ext" keys are required.

Returns

An integer representing the number of replies of the given type.  If the call fails for some reason, then false is returned.

getReplyArray
public function getReplyArray(
$params
)

Get an array of replies of a particular type.  This is for internal use only.  Call getComments(), getTrackbacks(), getPingbacks, or getReplies() instead of this.

Parameters
params

An associative array of settings, as in getReplyCount.  In addition to the keys allowed by that function, this one also requires a "creator" key, which is the name of a function that will return the correct type of object given the data path to its storage file as a parameter.  It also accepts an optional "sort_asc" key, which will sort the files in order by filename, (which equates to date order) rather than in reverse order when set to true.

Returns

An array of BlogComment, Trackback, or Pingback objects, depending on the parameters.  Returns false on failure.

getAllReplies

Gets an array of all replies to this entry.

Returns

An array of BlogComment, Trackback, and Pingback objects.

getCommentCount
public function getCommentCount()

Determine the number of comments that belong to this object.

Returns

A non-negative integer representing the number of comments or false on failure.

getComments
public function getComments(
$sort_asctrue
)

Gets all the comment objects for this entry.

Parameters
sort_asc

Optional boolean (true by default) determining whether the comments should be sorted in ascending order by date.

Returns

An array of BlogComment object.

getCommentArray
public function getCommentArray(
$sort_asctrue
)

Compatibility function, alias for getComments

getTrackbackCount
public function getTrackbackCount()

Get the number of TrackBacks for this object.

Returns

A non-negative integer representing the number of TrackBacks or false on failure.

getTrackbacks
public function getTrackbacks(
$sort_asctrue
)

Get an array that contains all TrackBacks for this entry.

Parameters
sort_asc

Optional boolean (true by default) determining whether the trackbacks should be sorted in ascending order by date.

Returns

An array of Trackback objects.

getTrackbackArray
public function getTrackbackArray(
$sort_asctrue
)

Compatibility function, alias for getTrackbacks

getPingbackCount
public function getPingbackCount()

Get the number of Pingbacks for this object.

Returns

A non-negative integer representing the number of Pingbacks or false on failure.

getPingbacks
public function getPingbacks(
$sort_asctrue
)

Get an array that contains all Pingbacks for this entry.

Parameters
sort_asc

Optional boolean (true by default) determining whether the pingbacks should be sorted in ascending order by date.

Returns

An array of Pingback objects.

getPingbackArray
public function getPingbackArray(
$sort_asctrue
)

Compatibility function, alias for getPingbacks

getPingbacksByType
public function getPingbacksByType()

Gets the local and remote pingbacks for an entry, i.e. pingbacks that come from URLs on the same blog as this entry and others.

Returns

An associative array with two keys, "local" and "remote".  Each element is an array of Pingback objects with the "friendly" pings in the "local" array and others in the "remote" array.

pingExists
public function pingExists(
$uri
)

Checks if a Pingback ping has already been recorded for the source URL.

Parameters
uri

The source URI to check.

Returns

True if there is already a recorded ping with the source URI, false otherwise.

writeFileData
public function writeFileData()

Overrides the default implementation to make sure that we always write to the correct file name.

getAttachments
public function getAttachments()

Get a list of files attached to this entry

Returns: Array of AttachedFile objects

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

Add an attached file to the entry.

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 entry.

Parameter
name

The name of the file to remove.

getManagedFiles
public function getManagedFiles()

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

Returns: An array of file names.

addReply
public function addReply(
$reply
)

Inserts a reply (comment, pingback, etc.) to the entry.

Parameters
reply

The reply object ot insert