Entry
LnBlogObject
abstract
Entry
BlogComment
BlogEntry

An abstract class representing entries of all types in the blog database.

Properties
file

The path to the file that holds data for this entry.  Note that this is specific to filesystem storage and is for internal use only.

has_html

Holds the type of markup used in the data property.  This can be one of several defined constants, includine MARKUP_NONE, MARKUP_BBCODE, and MARKUP_HTML.

custom_fields

An array of custom fields for the entry, with keys being the field name for use in the data structure and configuration files and the value being a short description to display to the user.

metadata_fields

An array of property->var pairs.  These are the object member variable names and the data file variable names respectively.  They are used to retreive data from persistent storage.

Functions
localpath
protected 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 called internally.

Returns

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

title
public function title(
$no_escapefalse
)

An RSS compatibility method for getting the title of an entry.

Parameters
no_escape

Optional boolean that tells the function to not escape ampersands and angle braces in the return value.

Returns

A string containing the title of this object.

description
public function description()

An RSS compatibility method.  Like title, but for the main text of the item.

Returns

A string containing HTML code for the item's text.

data
public function data(
$valuefalse
)

Set or return the data property.  If the optional value parameter is set to a true value (i.e. a non-empty string), then this value is set to the data property.  Otherwise, the data property is returned.

tags
public function tags(
$listfalse
)

Set or return an array of tags for this entry.  Each tag is an arbitrary string entered by the user with no inherent meaning.

permalink
public function permalink()

Abstract function that returns the object's permalink.  Child classes must over-ride this.

getParent
public function getParent()

Abstract function to return the parent object of the current object.  This will be a Blog object for BlogEntry or Article objects, and a BlogEntry or Article for BlogComment or TrackBack objects.  Child classes must over-ride this method.

markup
public function markup(
$data"",
$use_nofollowfalse
)

Apply appropriate markup to the entry data.

Parameters
data

Optional data to markup.  If not specified, use the data property of the current object.

use_nofollow

Apply rel="nofollow" to links.  Default is false.

Returns

A string with markup applied.

getAbstract
public function getAbstract(
$numchars500
)

A quick function to get a plain text abstract of the entry data by grabbing the first paragraph of text or the first N characters, whichever comes first.  Markup is removed in the process.  Note that it attempts to do word wrapping to avoid cutting words off in the middle.

Parameters
nuchars

Optional number of characters.  Defaults to 500.

A string containing the abstract text, with all markup stripped out.

getSummary
public function getSummary()

Gets a summary of the entry.  Returns the abstract property if it is set or the first HTML paragraph otherwise.

prettyDate
public function prettyDate(
$tsfalse
)

Get a human-readable date from a timestamp.

Parameters
ts

Optional timestamp for the date.  If unset, use time().

Returns

A string with a formatted, localized date.

readFileData
public function readFileData()

Reads entry data from a file.  As of verions 0.8.2, data is stored in XML format, with the elements corresponding directly to class properties.

In previous versions, file metadata is enclosed in META tags which are HTML comments, in one-per-line format.  Here is an example.  |<!--META Subject: This is a subject META--> Variables are created for every such line which is referenced in the metadata_fields property of the object.  The metadata_fields property is an associative array where the element key is the propery of the object to which the value is assigned and the element valueis the case-insensitive variable used in the file, as with "Subject" in the example above.

There is also a custom_fields property.  This is an associative array, just as metadata_fields.  If custom_fields is populated, its members are merged into metadata_fields, in effect adding elements to the standard metadata fields.

Returns

The body of the entry as a string.

writeFileData
public function writeFileData()

Write entry data to a file.  The contents of the file are determined by the properties of the object and the contents of the metadata_fields and custom_fields properties, just as with readFileData.  This function writes the metadata to HTML comments, as mentioned above, while the body data is written at the end of the file.  Note that, in order for the file to be written, the file property of the object must be set.

Returns

True if the file write is successful, false otherwise.

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.