Entry

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

Inherits

LnBlogObject

Summary
An abstract class representing entries of all types in the blog database.
An ID for the object that is unique across the class (not used).
The user ID of this object’s owner.
The IP address logged for this object at last modification.
The human-readable date when the object was last modified.
The UNIX timestamp when the object was last modified.
Human-readable date when the object was created.
UNIX timestamp when the object was created.
The subject text associated with this object.
An abstract of the text of this object (not used).
A comma-delimited list of tags applied to this entry.
The main text data of this object.
The path to the file that holds data for this entry.
Holds the type of markup used in the data property.
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.
An array of property->var pairs.
Set or return the data property.
Set or return an array of tags for this entry.
Abstract function that returns the object’s permalink.
Abstract function to return the parent object of the current object.
Gets a link to the object’s base directory, to use for converting relative to absolute paths.
Abstract function that converts a query string into a unique identifier for an object.
A function to search LBCode marked-up text and convert the URIs in links and images from relative to absolute.
A version of absolutizeBBCodeURI that works with HTML markup.
Strip HTML code out of a string.
Converts LBCode markup into HTML.
Apply appropriate markup to the entry data.
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.
Get a human-readable date from a timestamp.
Reads entry data from a file.
Write entry data to a file.

Properties

id

An ID for the object that is unique across the class (not used).

uid

The user ID of this object’s owner.

ip

The IP address logged for this object at last modification.

date

The human-readable date when the object was last modified.

timestamp

The UNIX timestamp when the object was last modified.

post_date

Human-readable date when the object was created.

post_ts

UNIX timestamp when the object was created.

subject

The subject text associated with this object.

abstract

An abstract of the text of this object (not used).

tags

A comma-delimited list of tags applied to this entry.

data

The main text data of this object.  May be one of several different kinds of markup.

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

data

function data($value = false)

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

function tags($list = false)

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

function permalink()

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

getParent

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.

baselink

function baselink()

Gets a link to the object’s base directory, to use for converting relative to absolute paths.  I some cases, this is just the permalink.

Returns

An absolute URI.

queryStringToID

function queryStringToID()

Abstract function that converts a query string into a unique identifier for an object.  Child classes must over-ride this function.

absolutizeBBCodeURI

function absolutizeBBCodeURI($data,
$current_uri)

A function to search LBCode marked-up text and convert the URIs in links and images from relative to absolute.

Parameters

dataThe string containing the LBCode markup to absolutize.
current_uriThe URI to which the relative links are relative.

Returns

A string with the markup in the data parameter, but with relative img and url tags converted to absolute URIs.  If the relative URI contains no slashes, colons, or ampersands, the relative URI given will be interpreted as under the under the current_uri parameter.  If it contains slashes, but no colons or ampersands, it will interpreted as relative to the blog root, if there is a current blog, and if the given URI starts with a slash, it will be interpreted as relative to the DOCUMENT_ROOT, if it is set.

absolutizeHTMLURI

function absolutizeHTMLURI($data,
$current_uri)

A version of absolutizeBBCodeURI that works with HTML markup.

Parameters

dataThe string containing the HTML markup to absolutize.
current_uriThe URI to which the relative links are relative.

Returns

The markup in the data parameter with href and src attributes absolutized according to the same rules as apply with absolutizeBBCodeURI.

stripHTML

function stripHTML($data)

Strip HTML code out of a string.  Note that the UNICODE_ESCAPE_HACK configuration constant can be used to switch between using the PHP htmlentities() and htmlspecialchars() functions to sanitize input.  This is because htmlentities() has a nasty habit of mangling Unicode.

Parameters

dataThe string to strip.

Returns

A copy of data with HTML special characters such as angle brackets and ampersands converted into their corresponding HTML entities.  This will cause them to display in a web page as characters, not HTML markup.

bbcodeToHTML

Converts LBCode markup into HTML.

Parameters

dataThe data string to convert.
stripOptional boolean indicating if the LBCode should just be stripped rather than converted.  Defaults to false.

Returns

A string with the converted text.

markup

function markup($data = "",
$use_nofollow = false)

Apply appropriate markup to the entry data.

Parameters

dataOptional data to markup.  If not specified, use the data property of the current object.
use_nofollowApply rel=”nofollow” to links.  Default is false.

Returns

A string with markup applied.

getAbstract

function getAbstract($numchars = 500)

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

nucharsOptional number of characters.  Defaults to 500.

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

prettyDate

function prettyDate($ts = false)

Get a human-readable date from a timestamp.

Parameters

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

Returns

A string with a formatted, localized date.

readFileData

function readFileData()

Reads entry data from a file.  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

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.

function data($value = false)
Set or return the data property.
function tags($list = false)
Set or return an array of tags for this entry.
function permalink()
Abstract function that returns the object’s permalink.
function getParent()
Abstract function to return the parent object of the current object.
function baselink()
Gets a link to the object’s base directory, to use for converting relative to absolute paths.
function queryStringToID()
Abstract function that converts a query string into a unique identifier for an object.
function absolutizeBBCodeURI($data,
$current_uri)
A function to search LBCode marked-up text and convert the URIs in links and images from relative to absolute.
function absolutizeHTMLURI($data,
$current_uri)
A version of absolutizeBBCodeURI that works with HTML markup.
function stripHTML($data)
Strip HTML code out of a string.
function markup($data = "",
$use_nofollow = false)
Apply appropriate markup to the entry data.
function getAbstract($numchars = 500)
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.
function prettyDate($ts = false)
Get a human-readable date from a timestamp.
function readFileData()
Reads entry data from a file.
function writeFileData()
Write entry data to a file.
A base object which is event-aware, i.e.
Use auto-markup.
Use LBCode markup, a bastardized version of BBCode.
Treat the markup as raw HTML, leaving it untouched.
Use an ugly hack with htmlentities() instead of the simpler htmlspecialchars() to deal with problems displaying Unicode characters.