auPage

From auWiki
Jump to navigation Jump to search

The auPage class is part of the auLib package. It provides functions for common page layout operations. It should be extended to handle the layout specific to a given website.

Usage

This class is meant to be extended as it includes only an incredibly basic layout. Every page on a website should create a page object for itself and use it for common layout operations.

Constants

_AU_PAGE_SITE_TITLE

If not defined already when auPage is included, this will get set to 'Generic Layout Class' and get used as the name of the website.

Protected Data

$started

True if the page has been started.

$ended

True if the page has ended.

$error

Any error messages that occurred before the page started.

$info

Any information messages that occurred before the page started.

$indent

Current indentation: should always be whitespace.

Public Functions

new auPage

new auPage()

Creates a new generic page layout object. If using a pages database, this is where the page record is looked up. This doesn't actually do anything, though it possibly should in classes that extend this class.

Error

Error($message, $detail)

Displays an error on the page. If the page hasn't been started yet, the error is saved and then displayed once the page starts.

  • $message = Error message.
  • $detail = Any details of the error. Default no details.

Info

Info($message)

Displays a message on the page. If the page hasn't been started yet, the message is saved and then displayed once the page starts.

  • $message = Informational message.

HasQueuedMessages

HasQueuedMessages()

Determines whether the page has queued messages to show.

  • @return = True if there are queued messages to show.

Start

Start($windowtitle, $title)

Writes out the part of the layout that comes before the page-specific content. Also writes any queued messages.

  • $windowtitle = Title of the page to be displayed in the browser titlebar.
  • $title = Title of the page, to be displayed on the page itself. Default is to use $windowvalue here too.

End

End()

Writes out the part of the layout that comes after the page-specific content.

Show404

Show404()

Sends a page not found header and then displays the 404 error page. Override this if your 404 page isn't /404.php.

Heading

Heading($heading, $id)

Writes out a heading on the page.

  • $heading = Text of the heading.
  • $id = ID of the heading, to work as #$id in links. Default is none.

SubHeading

SubHeading($heading, $id)

Writes out a sub-heading on the page.

  • $heading = Text of the sub-heading.
  • $id = ID of the sub-heading, to work as #$id in links. Default is none.


Protected Functions

Classes that extend auPage might find these functions useful, but they are not generally available.

FindParent

FindParent($url)

Finds the parent page that the current page belongs to. It takes into account both query string variables and directories.

  • $url = URL of the current page.
  • @return = URL of parent page.

ShowQueuedMessages

ShowQueuedMessages()

Displays all queued messages (errors and then information) on the page, once the page has been started.

Favicon

Favicon()

Writes out a link to the most specific favicon that can be found.

StyleSheets

StyleSheets()

Writes out a link to the relevant style sheets.

Scripts

Scripts($general)

Writes out a link to the relevant client-side scripts. This includes the general script and page- and/or directory-specific scripts found in the form /scripts/dir-subdir-page.js.

  • $general = Name of script file to include on all pages, without path or extension. Optional; default is general.