BlogThe “master” class which represents a weblog. Nearly all functions are performed through this object. This is the object that handles user security. InheritsLnBlogObject Events| OnInit | Fired when a blog object is created. | | InitComplete | Fired after the constructor has run. | | OnInsert | Run when a new blog is about to be created. | | InsertComplete | Run after a new blog object has been saved. | | OnUpdate | Run when a blog is about to be updated. | | UpdateComplete | Run after a blog is successfully updated. | | OnDelete | Run before a blog is deleted. | | DeleteComplete | Run after a blog is deleted. | | OnUpgrade | Run before the wrapper upgrade process. | | UpgradeComplete | Run when the wrapper upgrade is finished. | | OnEntryPreview | Run before populating entry template for preview. | | OnArticlePreview | Fired before populating article template for preview. | | OnEntryError | Fired before populating template when on an error. | | OnArticelError | Fired before populating template when on an error. |
Summary | The “master” class which represents a weblog. | | | | Determines whether the object represents an existing blog. | | Set and return the list of users who can add posts to the blog. | | Read and write a simple text file with the blog metadata. | | Save the blog data to disk. | | Get all the blog entries for a particular day. | | Get the number of posts made on a given day. | | Get a list of all entries for the specified month. | | Get the number of entries in the given month. | | Get a list of all years in the archive, sorted in reverse chronological order. | | Get a list of the months for the given year. | | Get a list of recent months, starting from the current month and going backward. | | Get the URL for the blog homepage. | | Get the URI of the designated resource. | | Get the most recent entries across all months and years. | | Convenience function to get “previous entries”. | | Scan entries in reverse chronological order, starting at a given offset, and get a given number of them. | | Get a list of entries tagged with a given string. | | Returns a list of all articles, in no particular order. | | Get a list of articles with title and permalink. | | Export blog variables to a PHPTemplate class. | | Gets the markup to display for the front page of a weblog. | | This is an upgrade function that will create new config and wrapper scripts to upgrade a directory of blog data to the current version. | | A quick utility function to fix the borked permissions from not setting the correct umask when creating directories. | | | | Modify an existing weblog. | | Removes an existing weblog. | | Adds any new tags to the list of tags used in the current blog. |
isBlogDetermines whether the object represents an existing blog. ReturnsTrue if the blog metadata exists, false otherwise.
writers| function writers( | $list | = | false | ) |
|
Set and return the list of users who can add posts to the blog. Parameters| list | an arrays or comma-delimited stringof user names. |
ReturnsAn array of user names.
readBlogDataRead and write a simple text file with the blog metadata. Format is key = data, each record is a single line, unrecognized keys are ignored. This is for internal use only.
writeBlogDataSave the blog data to disk. This is for internal use only. ReturnsFalse on failure, something else on success.
getDay| function getDay( | $year, | | $month, | | $day | ) |
|
Get all the blog entries for a particular day. Parameters| year | The year you want. | | month | The month you want. | | day | The day you want. |
ReturnsAn array of BlogEntry objects posted on the given date, sorted in reverse chronological order by post time.
getDayCount| function getDayCount( | $year, | | $month, | | $day | ) |
|
Get the number of posts made on a given day. Parameters| year | The 4 digit year of the post. | | month | The month of the post. | | day | The day of the post. |
RetrunsAn integer representing how many posts were made that day.
getMonth| function getMonth( | $year | = | false, | | $month | = | false | ) |
|
Get a list of all entries for the specified month. If you do not specify a year and month, then the routine will try to get it from the current directory and/or URL. Parameters| year | Optional year you want. | | month | Optional month you want. |
ReturnsAn array of BlogEntry objects posted in the given month, sorted in reverse chronological order by post date.
getMonthCount| function getMonthCount( | $year | = | false, | | $month | = | false | ) |
|
Get the number of entries in the given month. If no month and year are given, try to get them from the current directory/URL. Parameters| year | Optional year you want. | | month | Optional month you want. |
ReturnsA non-negative integer representing the number of posts in that month.
getYearListGet a list of all years in the archive, sorted in reverse chronological order. ReturnsA two-dimensional array. The first dimension has numeric indexes. The second has two elements, indexed as “year” and “link”, which hold the 4-digit year and a permalink to the archive of that year respectively.
getMonthList| function getMonthList( | $year | = | false | ) |
|
Get a list of the months for the given year. If no year is given, try to extract it from the current directory/URL. ParametersReturnsA two-dimensional array. The first dimension is numerically indexed, with elements sorted in reverse chronological order. The second dimension has three elements, indexed as “year”, “month”, and “link”. These hold, respectively, the year you specified, the 2-digit month, and a permalink to the archive for that month.
getRecentMonthList| function getRecentMonthList( | $nummonths | = | 12 | ) |
|
Get a list of recent months, starting from the current month and going backward. This is essentially a wrapper around getMonthList. Parameters| nummonths | Optional number of months to return. The default is 12. If set to zero or less, then all months will be retreived. |
ReturnsAn array of the most recent months in the same format used by getMonthList. The total length of the first dimension of the array should be nummonths long.
getURL| function getURL( | $full_uri | = | true | ) |
|
Get the URL for the blog homepage. Parameters| full_uri | Optional boolean for whether or not to return a full URI or a root-relative one. Default is true. |
ReturnsA string holding the URI to the blog root directory.
uriGet the URI of the designated resource. Parameters| type | The type of URI to get, e.g. permalink, edit link, etc. | | data parameters | All other parameters after the first are interpreted as additional data for the URL. The parameters are expected to be strings of the form “key=val”. Note that not all types of URI accept parameters. |
ReturnsA string with the permalink.
getRecent| function getRecent( | $num_entries | = | false | ) |
|
Get the most recent entries across all months and years. Parameters| num_entries | Optional number of entries to return. The default is to use the <max_entries> property of the blog. If -1 is passed, then all entries in the blog will be returned. |
ReturnsAn array of BlogEntry objects.
getNextMax| function getNextMax( | $num_entries | = | false | ) |
|
Convenience function to get “previous entries”. Returns a list of entries starting after the the end of the blog’s <max_entires> property. Parameters| num_entries | The optional number or entries to return. The default is to use the blog’s <max_entries> property. |
ReturnsAn array of BlogEntry objects.
getEntries| function getEntries( | $number, | | | $offset | = | ) |
|
Scan entries in reverse chronological order, starting at a given offset, and get a given number of them. Parameters| number | The number of entries to return. If set to -1, then returns all entries. | | offset | Optional number of entries from the beginning of the list to skip. The default is 0, i.e. start at the beginning. |
ReturnsAn array of BlogEntry objects.
getEntriesByTag| function getEntriesByTag( | $taglist, | | | | $limit | = | 0, | | $match_all | = | false | ) |
|
Get a list of entries tagged with a given string. Parameter| taglist | An array of tags to search for. | | limit | Maximum number of entries to return. The default is zero, which me !;!/an return all matching entries. | | match_all | Optional boolean that determines whether the entry must have every tag in taglist to match. The default is false. |
ReturnsAn array of entry objects, in reverse chronological order by post date.
getArticlesReturns a list of all articles, in no particular order. ReturnsAn array of Article objects.
getArticleList| function getArticleList( | $number | = | false, | | $sticky_only | = | true | ) |
|
Get a list of articles with title and permalink. Parameters| number | Optional number of articles to return. Default is all. | | sticky_only | Optionally return only “sticky” articles. Default is true. |
ReturnsA two-dimensional array. The first is numerically indexed. The second is two elements indexed as “title” and “link”. These represent the title of the article and the permalink to it respectively.
exportVars| function exportVars( | & | $tpl | ) |
|
Export blog variables to a PHPTemplate class. This is for internal use only. Parameters| tpl | The PHPTemplate to populate. |
getWeblogGets the markup to display for the front page of a weblog. ReturnsA string holding the HTML to display.
upgradeWrappers| function upgradeWrappers () |
This is an upgrade function that will create new config and wrapper scripts to upgrade a directory of blog data to the current version. The data files should always work unmodified, so they do not need to be upgraded. This should not be required too often, if all goes well. PreconditionIt is assumed that this function will only be run from the package installation directory. ReturnsTrue on success, false on failure.
fixDirectoryPermissions| function fixDirectoryPermissions( | $start_dir | = | false | ) |
|
A quick utility function to fix the borked permissions from not setting the correct umask when creating directories. This resulted in directories that I couldn’t alter via FTP. Parameters| start_dir | The directory to fix. Defaults to the blog root. |
ReturnsTrue on success, false otherwise.
insert| function insert ( | $path | = | false | ) |
|
Creates a new weblog. Parameters| path | The path to the blog root. Defaults to the current directory. |
ReturnsTrue on success, false otherwise.
updateModify an existing weblog. ReturnsTrue on success, false otherwise.
deleteRemoves an existing weblog. ReturnsTrue on success, false on failure.
updateTagList| function updateTagList( | $tags | ) |
|
Adds any new tags to the list of tags used in the current blog. Parameters| tags | An array of strings holding the tags to be added. Duplicates are removed. |
ReturnsTrue on success, false on failure.
|