Class: Document

This package contains the data of the current page request, and renders it for the
Sitellite Content Server. It also provides several global-level functions that
provide developers with control over the contents and the properties of the page
request.



Properties


$vals

  • Access: public

List of values to alternate between.


$counter

  • Access: private

The internal position counter.


$current

  • Access: private

Always keeps the value of the current array position here.


$headers = array ()

List of HTTP headers to be sent with the document. @see addHeader()


$meta = array ()

List of metadata attributes, which can be rendered as HTML meta tags using
the makeMeta() method. To render them into your XT templates, simply
add an xt:var tag with the name "makeMeta".


$scripts = array ()

List of javascript scripts, which can be rendered as HTML script tags using
the makeJavascript() method. To render them into your XT templates, simply
add an xt:var tag with the name "makeJavascript".


$styles = array ()

Array used to prevent duplicate loading of stylesheets.


$template_set = 'default'

The template set to use for output.

Return to Top



Methods


Document ($data = array ())

Constructor method. If $data is passed to the constructor, it will pass the
$data on to the set() method.


set ($data = array ())

Sets properties of the current Document object, such as title, id, body, etc.


addHeader ($header)

Adds an HTTP header to send when compile() is called.


sendHeaders ()

Sends all HTTP headers associated with the current document.
Called by compile() automatically.


addMeta ($key, $value, $name = 'name')

Adds a metadata property to the global template.


makeMeta ()

  • Return: string

Note: Deprecated in favour of XT's automatic tag binding capabilities.
Compiles the metadata properties of the current document into HTML meta tags,
which are returned as one big XHTML-compliant string.


addScript ($script)

Adds a script to the global template.


addStyle ($style)

Adds a stylesheet to the global template.


makeJavascript ()

  • Return: string

Note: Deprecated in favour of XT's automatic tag binding capabilities.
Compiles the javascript of the current document into HTML script tags,
which are returned as one big XHTML-compliant string.


addLink ($rel, $type, $href, $charset = false, $hreflang = false, $name = false)

Adds a link tag to the global template.


compile ()

  • Return: string

"Compiles" the document. This includes sending any headers, checking
isExternal(), then calling useTemplate() to render the document to the
appropriate template.


isExternal ()

Checks for an $external property of the document object, which if found
is understood to represent an external document that this object is
actually an alias of, and so it will forward the request on to that
document.


useTemplate ()

  • Return: string

Determines which template to use to render the document for output
to the visitor. The template is chosen based on the following
conditions:

- Templates all live in inc/html in individual template set directories
(ie. themes). The template set can be specified with page_template_set(),
or via the default_template_set configuration option.
- The $cgi->mode value, which defaults to "html" if unspecified
- The $template property of this object is appended to the mode like
this: html.index.tpl where html is the mode and index is the $template
value. The template can be specified with the page_template() function,
or via the default_template configuration option.
- If that document is not found, we then check for such a document
based on the names of parent documents in the hierarchy, but only
those that are designated as section roots. Each of these is then
used as a replacement for the $template property.
- If none is found, then the default html.{default_template}.tpl is used,
where html is the mode.

Note that the templates are always in XT format. For info on the XT template
language, see the class documentation under XML/XT at sitellite.org/docs


getSection ()

  • Return: string

Returns the section name of the current page, or false if the page is
not in any section. A section is a page that has its 'is_section'
property set to true in $menu, and is set under the 'Properties' tab
of the Sitellite web page editor in the field named 'Is This a Section
Index?'. Section pages differ from ordinary pages in that their
template setting (also under the 'Properties' tab) will inherit to
all child pages, unless those pages explicitly declare their own
template.


getTitle ($page = false)

  • Return: string

Gets the title of the current or the specified page.


isParent ($parent)

  • Return: boolean

Determines whether the specified page ID is a parent of the current
page.

Return to Top

Copyright © 2008 Sitellite CMS Project

Powered by Sitellite 5.0 Content Management System