Entry

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

Summary
EntryAn abstract class representing entries of all types in the blog database.
Properties
fileThe path to the file that holds data for this entry.
has_htmlHolds the type of markup used in the data property.
custom_fieldsAn 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_fieldsAn array of property->var pairs.
Functions
localpathGet the path to this entry’s directory on the local filesystem.
titleAn RSS compatibility method for getting the title of an entry.
descriptionAn RSS compatibility method.
dataSet or return the data property.
tagsSet or return an array of tags for this entry.
permalinkAbstract function that returns the object’s permalink.
getParentAbstract function to return the parent object of the current object.
baselinkGets a link to the object’s base directory, to use for converting relative to absolute paths.
queryStringToIDAbstract function that converts a query string into a unique identifier for an object.
markupApply appropriate markup to the entry data.
getAbstractA 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.
getSummaryGets a summary of the entry.
prettyDateGet a human-readable date from a timestamp.
readFileDataReads entry data from a file.
writeFileDataWrite entry data to a file.

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_escape = false)

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

Parameters

no_escapeOptional 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($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

public 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

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.

baselink

public 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

public function queryStringToID()

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

markup

public 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

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

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($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

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.

protected function localpath()
Get the path to this entry’s directory on the local filesystem.
public function title($no_escape = false)
An RSS compatibility method for getting the title of an entry.
public function description()
An RSS compatibility method.
public function data($value = false)
Set or return the data property.
public function tags($list = false)
Set or return an array of tags for this entry.
public function permalink()
Abstract function that returns the object’s permalink.
public function getParent()
Abstract function to return the parent object of the current object.
public function baselink()
Gets a link to the object’s base directory, to use for converting relative to absolute paths.
public function queryStringToID()
Abstract function that converts a query string into a unique identifier for an object.
public function markup($data = "",
$use_nofollow = false)
Apply appropriate markup to the entry data.
public 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.
public function getSummary()
Gets a summary of the entry.
public function prettyDate($ts = false)
Get a human-readable date from a timestamp.
public function readFileData()
Reads entry data from a file.
public function writeFileData()
Write entry data to a file.
Use auto-markup.
Use LBCode markup, a bastardized version of BBCode.
Treat the markup as raw HTML, leaving it untouched.
Close