AnewtPage class

Class for building XHTML pages.

Class Overview

Class for building XHTML pages.

Public Methods

__construct()

Create a new AnewtPage instance.

Stylesheet methods

These methods allow you to add stylesheets to the page.

add_stylesheet($node)

Add a stylesheet node to the page.

This function accepts either a AnewtXHTMLStyle or an AnewtXHTMLLink element, e.g. created by ax_stylesheet() or ax_stylesheet_href(). Usually you should use add_stylesheet_href() or add_stylesheet_href_media() instead.

Parameters

$node

A AnewtXHTMLStyle or AnewtXHTMLLink (referring to a stylesheet) node.

See also

add_stylesheet_href($href)

Add an external stylesheet reference to the page.

Parameters

$href

The location of the external stylesheet

See also

add_stylesheet_href_media($href, $media)

Add an external stylesheet reference to the page.

Parameters

$href

The location of the external stylesheet

$media

The media type for which this stylesheet is intended, e.g. print or screen.

See also

JavaScript methods

These methods allow you to add JavaScript to the page.

add_javascript($node)

Add JavaScript to this page.

This function accepts a AnewtXHTMLScript node, e.g. one created using ax_javascript(). Use the add_javascript_src() and add_javascript_content() methods to easily add stylesheets to the page without creating the node yourself.

Parameters

$node

A AnewtXHTMLScript node.

See also

add_javascript_src($src)

Add a JavaScript reference to this page for the given source file.

Parameters

$src

Source of the JavaScript file

add_javascript_content($content)

Add a JavaScript to this page for the given content.

Parameters

$content

Scripts contents.

Linking methods

These methods should be used to link other resources to this page.

Content methods

These methods should be used to add content to the page.

append($new_child)

Append new content to this page.

For simple pages this method just adds some content to the page. For block-based pages, this method adds content to the default block.

Parameters

$new_child

The content to add. This is most likely an Anewt XHTML element instance, e.g. created by the ax_* functions from the XHTML module. Numerical arrays are also accepted.

See also

append_to($name, $new_child)

Append new content to a block on this page.

This method can only be used for block-based pages.

Note that the specified block is not required to be specified in the blocks property, though in most cases it will be (if you want it to be rendered at least). In some custom situations where you build blocks by other means, i.e. using build_* methods on your page subclass, it might be helpful to use custom block names to act as temporary containers for the page content. The build_* methods can then retrieve the value and do something smart with it.

Parameters

$name

The name of the block to which the content should be added.

$new_child

The content to add. This is most likely an Anewt XHTML element instance, e.g. created by the ax_* functions from the XHTML module. Numerical arrays are also accepted.

See also

get_block($name) [protected]

Get the contents of a block.

This method returns the content of the block as an AnewtXMLDomNode instance, or null if no content was set for the requested block.

Parameters

$name

The name of the block to retrieve.

Return value

An AnewtXMLDomNode instance or null if the block did not contain any content.

Output methods

render()

Render this page into XHTML.

This methods renders the whole page into a complete XHTML page. Usually you want to use flush() to output the page to the browser.

Return value

The rendered page as a string.

See also

flush()

Flush this page to the browser.

This method renders the page into a XHTML string and outputs it to the browser along with the correct HTTP headers.

See also

build_content_type_charset() [private]

Build a content type and character set string.

Private Attributes

$_content [private]

Page content.

$_blocks [private]

Associative array of blocks.

$_javascripts [private]

List of JavaScript nodes.

Inheritance

Base Classes

Inherited members