BlogEntry

Represents an entry in the weblog.

Inherits

LnBlogObject, Entry

Events

OnInitFired when object is first created.
InitCompleteFired at end of constructor.
OnInsertFired before object is saved to persistent storage.
InsertCompleteFired after object has finished saving.
OnDeleteFired before object is deleted.
DeleteCompleteFired after object is deleted.
OnUpdateFired before changes are saved to persistent storage.
UpdateCompleteFired after changes to object are saved.
OnOutputFired before output is generated.
OutputCompleteFired after output has finished being generated.
POSTRetrievedFired after data has been retreived from an HTTP POST.
Summary
BlogEntryRepresents an entry in the weblog.
Functions
getParentGet a copy of the parent of this objcet, i.e.
entryIDGets an identifier for the current entry.
globalIDA unique ID for use with blogging APIs.
parentIDGets an identifier for the entry’s parent blog.
getUploadedFilesGets an array of the names of all files uploaded to this entry.
getEnclosureGets the URL, file size, and media type of the file set as the enclosure for this entry, it if exists.
getPathReturns a path to use for the entry.
isEntryDetermine if the object is a blog entry or not.
isDraftChecks if the given entry is saved as a draft, as opposed to a published blog entry.
localpathGet the path to this entry’s directory on the local filesystem.
permalinkGet the permalink to the object.
baselinkReturns a link to the object’s base directory.
commentlinkGet the permalink to the object.
uriGets the URI of the a specified page.
updateCommit changes to the object.
deleteDelete the current object.
insertSave the object to persistent storage.
publishDraftPublishes a draft entry as an actual blog entry.
saveDraftSaves the object as a draft, which can be recalled, edited, and published latter.
calcPrettyPermalinkCalculates a file name for a “pretty” permalink wrapper script.
makePrettyPermalinkCreates a wrapper script that makes a “pretty” permalink to the entry directory based on the subject text of the entry.
getPostDataExtract data from an HTTP POST and insert it into the object.
exportVarsSets template variables with the entry data.
getGet the HTML to use to display the entry summary.
getFullGet the HTML to use to display the full entry page.
getReplyCountGet the number of replies of a particular type.
getReplyArrayGet an array of replies of a particular type.
getAllRepliesGets an array of all replies to this entry.
getCommentCountDetermine the number of comments that belong to this object.
getCommentsGets all the comment objects for this entry.
getCommentArrayCompatibility function, alias for getComments
getTrackbackCountGet the number of TrackBacks for this object.
getTrackbacksGet an array that contains all TrackBacks for this entry.
getTrackbackArrayCompatibility function, alias for getTrackbacks
getPingbackCountGet the number of Pingbacks for this object.
getPingbacksGet an array that contains all Pingbacks for this entry.
getPingbackArrayCompatibility function, alias for getPingbacks
getPingbacksByTypeGets the local and remote pingbacks for an entry, i.e.
sendPingsScans the links in the current entry, determines which are pingback-enabled, and sends a pingback ping to those links.
pingExistsChecks if a Pingback ping has already been recorded for the source URL.
extractLinksExtracts all the hyperlinks from the entry text.

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.

parentID

public function parentID()

Gets an identifier for the entry’s parent blog.

Returns

For file-based storage, returns the webroot-relative path to the blog.

getUploadedFiles

public function getUploadedFiles()

Gets an array of the names of all files uploaded to this entry.  Currently, this just means all files in the entry directory that were not created by LnBlog.

Returns

An array containing the file names without path.

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_name = false,
$long_format = false)

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

Parameters

curr_tsThe timestamp for this entry.
just_nameOptional boolean determining whether to return a full path or just a file name.  Default is false.
long_formatOptional 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.

isEntry

public function isEntry ($path = false)

Determine if the object is a blog entry or not.

Parameter

pathOptional 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($path = false)

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.

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.

baselink

public function baselink()

Returns a link to the object’s base directory.

Returns

A string with the URI.

commentlink

Get the permalink to the object.

uri

public function uri($type)

Gets the URI of the a specified page.

Parameters

linkThe page for which you want the URI.  Valid values are “page”, “

Returns

A string holding the relevant URI.

update

public function update ()

Commit changes to the object.

Returns

True on success, false on failure.

delete

public function delete ()

Delete the current object.

Returns

True on success, false on failure.

insert

public function insert ($blog,  
$from_draft = false)

Save the object to persistent storage.

Parameters

blogThe blog into which the entry will be inserted.
from_draftIndicates that the entry will be inserted from a draft entry, not created directly from user input.  Returns: True on success, false on failure.

publishDraft

public function publishDraft(&$blog)

Publishes a draft entry as an actual blog entry.  This is an alias for BlogEntry::insert($blog, true).

saveDraft

public function saveDraft(&$blog)

Saves the object as a draft, which can be recalled, edited, and published latter.

calcPrettyPermalink

public function calcPrettyPermalink($use_broken_regex = false)

Calculates a file name for a “pretty” permalink wrapper script.

Parameters

use_broken_regexOptional 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

subjectThe subject of the entry, in plain text.
short_pathThe “short path” to access an article.
abstractAn abstract of the entry, with markup.
tagsA comma-delimited list of free-form tags.
bodyThe entry body, with markup.
commentsBoolean representing whether new comments can be posted.
input_modeTristate 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_controls = false)

Sets template variables with the entry data.

Parameters

tmpThe template we wish to populate.

get

public function get($show_edit_controls = false)

Get the HTML to use to display the entry summary.

Parameters

show_edit_controlsOptional 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_controls = false)

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

Parameters

show_edit_controlsOptional 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

parmsAn 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

paramsAn 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_asc = true)

Gets all the comment objects for this entry.

Parameters

sort_ascOptional 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_asc = true)

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_asc = true)

Get an array that contains all TrackBacks for this entry.

Parameters

sort_ascOptional 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_asc = true)

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_asc = true)

Get an array that contains all Pingbacks for this entry.

Parameters

sort_ascOptional 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_asc = true)

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.

sendPings

public function sendPings($local = false)

Scans the links in the current entry, determines which are pingback-enabled, and sends a pingback ping to those links.

Parameters

localOptional boolean that determines whether or not to send pings to posts on the same webserver.  Defaults to false.  Returns: An array of associative arrays.  Each array has ‘uri’ and a ‘response’ key, which contain the target URI and the XML-RPC response object.

pingExists

public function pingExists ($uri)

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

Parameters

uriThe source URI to check.

Returns

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

extractLinks

public function extractLinks($allow_local = false)

Extracts all the hyperlinks from the entry text.

Parameters

allow_localOptional boolean parameter that determines if local links, should be included.  Defaults to false.

Returns

An array of URLs containing each hyperlink in the entry.  If allow_local is false, then links without a protocol and host name are excluded.

public function getParent()
Get a copy of the parent of this objcet, i.e.
public function entryID()
Gets an identifier for the current entry.
public function globalID()
A unique ID for use with blogging APIs.
public function parentID()
Gets an identifier for the entry’s parent blog.
public function getUploadedFiles()
Gets an array of the names of all files uploaded to this entry.
public function getEnclosure()
Gets the URL, file size, and media type of the file set as the enclosure for this entry, it if exists.
public function getPath($curr_ts,  
$just_name = false,
$long_format = false)
Returns a path to use for the entry.
public function isEntry ($path = false)
Determine if the object is a blog entry or not.
public function isDraft($path = false)
Checks if the given entry is saved as a draft, as opposed to a published blog entry.
public function localpath()
Get the path to this entry’s directory on the local filesystem.
public function permalink()
Get the permalink to the object.
public function baselink()
Returns a link to the object’s base directory.
public function uri($type)
Gets the URI of the a specified page.
public function update ()
Commit changes to the object.
public function delete ()
Delete the current object.
public function insert ($blog,  
$from_draft = false)
Save the object to persistent storage.
public function publishDraft(&$blog)
Publishes a draft entry as an actual blog entry.
public function saveDraft(&$blog)
Saves the object as a draft, which can be recalled, edited, and published latter.
public function calcPrettyPermalink($use_broken_regex = false)
Calculates a file name for a “pretty” permalink wrapper script.
public function makePrettyPermalink()
Creates a wrapper script that makes a “pretty” permalink to the entry directory based on the subject text of the entry.
public function getPostData()
Extract data from an HTTP POST and insert it into the object.
public function exportVars(&$tmp,  
$show_edit_controls = false)
Sets template variables with the entry data.
public function get($show_edit_controls = false)
Get the HTML to use to display the entry summary.
public function getFull($show_edit_controls = false)
Get the HTML to use to display the full entry page.
public function getReplyCount($params)
Get the number of replies of a particular type.
public function getReplyArray($params)
Get an array of replies of a particular type.
public function getCommentCount()
Determine the number of comments that belong to this object.
public function getComments($sort_asc = true)
Gets all the comment objects for this entry.
public function getCommentArray($sort_asc = true)
Compatibility function, alias for getComments
public function getTrackbackCount()
Get the number of TrackBacks for this object.
public function getTrackbacks($sort_asc = true)
Get an array that contains all TrackBacks for this entry.
public function getTrackbackArray($sort_asc = true)
Compatibility function, alias for getTrackbacks
public function getPingbackCount()
Get the number of Pingbacks for this object.
public function getPingbacks($sort_asc = true)
Get an array that contains all Pingbacks for this entry.
public function getPingbackArray($sort_asc = true)
Compatibility function, alias for getPingbacks
public function getPingbacksByType()
Gets the local and remote pingbacks for an entry, i.e.
public function sendPings($local = false)
Scans the links in the current entry, determines which are pingback-enabled, and sends a pingback ping to those links.
public function pingExists ($uri)
Checks if a Pingback ping has already been recorded for the source URL.
public function extractLinks($allow_local = false)
Extracts all the hyperlinks from the entry text.
A base object which is event-aware, i.e.
An abstract class representing entries of all types in the blog database.
Use auto-markup.
Use LBCode markup, a bastardized version of BBCode.
Treat the markup as raw HTML, leaving it untouched.
Close