Page
LnBlogObject
Page

Represents a web page.  This class is primarily concerned with making sure that the things in the HEAD part of the page are set up correctly.

Inherits

LnBlogObject

Events
OnInit

Fired when a page object is first created.

InitComplete

Fired after object initialization is complete.

OnOutput

Fired when processing for HTML output starts.

OutputComplete

Fired after the HTML output has been performed.

Properties
display_object

Holds a reference to the primary object which is displayed on this page.  The type of object will vary from page to page and may be set to false on some pages.  For most pages, it will be the current Blog object, but BlogEntry and Article object are also common.

doctype

String holding the DOCTYPE for the page.  Should normally be set using a named constant.

title

A string used for the page title.

mime_type

Represents the MIME type of the page.

charset

Holds the character encoding to use for the page.

Functions
instance
public static function instance()

Get the instance for the page singleton.

addPackage
public function addPackage(
string $name
)

Adds a third-party package to the page, e.g. jQuery.

Parameters
name
string$

The name of the package to add

setDisplayObject
public function setDisplayObject(
$ref
)

Sets the object which the page is currently displaying.

Parameters
ref

A reference to the object to set.

addStylesheet
public function addStylesheet()

Adds style sheets to be link into the page.

Parameters

Takes a variable number of string parameters, each representing the filename of a CSS file.

addInlineStylesheet
public function addInlineStylesheet()

Adds style sheets to be added inline into the page.

Parameters

Takes a variable number of string parameters, each containing the CSS code to use for the inline styles.

addLink
public function addLink(
$attribs
)

Adds a generic link element to the page header.

Parameters
attribs

An associative array, with each key corresponding to an attribute of the link with the corresponding value as the value.

addRSSFeed
public function addRSSFeed(
$href,
$type,
$title
)

Adds an RSS feed to the link elements of the page header.

Parameters
href

The URL of the feed file.

type

The MIME type of the feed, e.g. application/xml or application/rss+xml

title

The title for the feed.

addScript
public function addScript(
$href,
$type"text/javascript"
)

Adds a script file to the header of the page.

Parameters
href

The URL of the script file.

type

Optional MIME type of the script.  The default is text/javascript.

addInlineScript
public function addInlineScript(
$text,
$type"text/javascript"
)

Adds an inline script to the header of the page.

Parameters
text

The text of the script to add inline.

type

Optional MIME type of the script.  The default is text/javascript.

addExternalScript
public function addExternalScript(
$href,
$type"text/javascript"
)

Add a script file from an external URL to the page.

addExternalStylesheet
public function addExternalStylesheet(
$href
)

Add a stylesheet from an external URL to the page.

addScriptFirst
public function addScriptFirst(
$href,
$type"text/javascript"
)

Like addScript, except adds the script at the beginning of the list of scripts to be inserted.  Use this for initialization of configuration scripts that need to run before other things.

addInlineScriptFirst
public function addInlineScriptFirst(
$text,
$type"text/javascript"
)

Like addScriptFirst, except for inline scripts.

addMeta
public function addMeta(
$content,
$namefalse,
$httpequivfalse
)

Adds a META item to the page.

Parameters
content

The content of the meta tag.

name

Optional name attribute.

httpequiv

Optional http-equiv attribute.

addHeader
public function addHeader(
$name,
$content
)

Add an item to the HTTP header for the page.

Parameters
name

The header name.

content

The content of the header.

redirect
public function redirect(
$url
)

Redirect to another page.

Parameters
url

The target URL to which to redirect.

refresh
public function refresh(
$url,
$delay0
)

Refresh the page.

Parameters
url

The URL of the page to refresh.

delay

Optional delay of refresh.  Default is 0.

display
public function display(
$page_body,
$blogfalse
)

Displays the page, i.e. sends it to the browser.

error
public function error(
$code,
$extra_message ''
)

Set an error header and exit.

Parameters
error

The HTTP status code for the response.

extra_message

An additional message to output for the response