PageRender2 Class Reference

A class that collects content and renders it to an output (web) page. More...

Inheritance diagram for PageRender2:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 __construct ($format="")
 Creates a new PageRender2 object.
 add ($component, $options=array())
 Add a TK component to the PR2 page.
 dropCache ($uri=null)
 Clear the page cache for uri $uri.
 flash ($string="")
 Add "flash" text to the page.
 flashAndExit ($string="")
 "Flash" text to the page, print the page, then exit
 flashAndRedirect ($string, $url)
 Store "flash" text in the session to be displayed on the next page, then redirect.
 formatError ($format, $title, $error, $indent=0)
 INSERT BRIEF DESCRIPTION HERE.
 getClass ($key)
 INSERT BRIEF DESCRIPTION HERE.
 getClassInstance ($key)
 Get a class instance that PR2 is storing, for a re-used class such as a translator.
 getDefault ($key)
 Retrieves PR2 default.
 getInput ($key)
 INSERT BRIEF DESCRIPTION HERE.
 getLayout ()
 Get the active SLayout for this PR2 instance.
 getOption ($key)
 Get the value of an option.
 getPage ()
 Get the SPage object.
 getPageTemplate ()
 Get the active SPageTemplate for this PR2 instance.
 includeCSS ($filename, $root= '')
 Include a link to a CSS file in the page head.
 includeJS ($filename, $root= '')
 Include a link to a javascript file in the page head.
 load ($input, $options=array(), $name="")
 Load content into the page using a translator.
 loadCSS ($css)
 Load literal CSS to the ExtraCSS slot.
 loadJS ($js, $slot= 'ExtraJS')
 Load literal javascript to the ExtraJS slot (or another slot).
 rebaseCserdUrls ($enable=true, $projectUrl=false)
 INSERT BRIEF DESCRIPTION HERE.
 render ()
 Render the page content, store it in the SPage buffer.
 renderPrint ($format="html")
 Render the page to the page buffer, then print it out.
 setClass ($key, $value)
 INSERT BRIEF DESCRIPTION HERE.
 setOption ($key, $value)
 Set a value for an option (to override a default value).
 setToolkitTheme ($theme)
 INSERT BRIEF DESCRIPTION HERE.
 updateCachedVersion ()
 Add this page content to the cache manager.
 useCachedVersion ($lifetime="")
 Tell PR2 to use the cached version of a page instead of rendering each time.

Protected Member Functions

 runTestSuite ($extras=null)
 Build a report to tell a user agent whether the page has errors.


Detailed Description

A class that collects content and renders it to an output (web) page.

PageRender2 is a framework for assembling a web page using any number of inputs. It is similar to a templating system, but is not the same thing. PR2 allows you to load any number of inputs in any number of different formats into a set of "slots" in your page.

The page can also be output in any format. You simply choose the translator for each piece of input, the target slot, the page layout (how the slots are assembled into an output format), and the page tempate (what parts of the page show). Then you can renderPrint your page.

Author:
Jonathan (<jwsm@shodor.org>)
Date:
6-4-07

5-37-07

Fall '06


Constructor & Destructor Documentation

PageRender2::__construct ( format = ""  ) 

Creates a new PageRender2 object.

Detailed description

Parameters:
$format [string]: which output format this object will produce (e.g., 'html', etc.)


Member Function Documentation

PageRender2::add ( component,
options = array() 
)

Add a TK component to the PR2 page.

Load a TK component into the page using STransTK

Parameters:
$component [TKComponent]: The TK component to be added to the page
$options [array]: Additional translation options (as used with load())

PageRender2::dropCache ( uri = null  ) 

Clear the page cache for uri $uri.

Parameters:
$uri [string]: The URI for which we want to clear the page cache

PageRender2::flash ( string = ""  ) 

Add "flash" text to the page.

Append "flash" text (i.e., messages flashed to the user at the top of the page) to the flash slot. A page template may or may not display this slot.

Parameters:
$string [string]: The flash text

PageRender2::flashAndExit ( string = ""  ) 

"Flash" text to the page, print the page, then exit

Use this function to present a fatal error message/access denied message to the user in the nicest way, then exit immediately.

Parameters:
$string [string]: The flash text

PageRender2::flashAndRedirect ( string,
url 
)

Store "flash" text in the session to be displayed on the next page, then redirect.

Store "flash" text to be displayed to the user at the top of the next page using the SWAT global user object. Then redirect to that page. If that page is set up to display flash text, the text will appear there when the user arrives. This works well for showing confirmation messages after handling events/form submissions.

Parameters:
$string [string]: The flash text
$url [string]: The destination URL to redirect to

PageRender2::formatError ( format,
title,
error,
indent = 0 
)

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$format [TYPE]: DESCRIPTION
$title [TYPE]: DESCRIPTION
$error [TYPE]: DESCRIPTION
$indent [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::getClass ( key  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$key [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::getClassInstance ( key  ) 

Get a class instance that PR2 is storing, for a re-used class such as a translator.

Look for a stored instance of the class named $key. If it does not exist, create and store it Return it to the caller. This is used to buffer instances of translator objects so that they can be re-used.

Parameters:
$key [string]: The name of the class for which we want a stored instance
Returns:
[mixed]: The stored instance of the class named $key, or false if the class is not found

PageRender2::getDefault ( key  ) 

Retrieves PR2 default.

Defaults store the default values of preferences for PR2, such as what the default input and output formats are, and what the default translator is for each input format.

Parameters:
$key [string]: which default to retrieve
Returns:
[string]: value of the default for the given key or empty string if key is invalid

PageRender2::getInput ( key  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$key [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::getLayout (  ) 

Get the active SLayout for this PR2 instance.

Get the SLayout object or subclass that represents the current page layout for this PR2 instance.

Returns:
[SLayout]: The page layout object

PageRender2::getOption ( key  ) 

Get the value of an option.

If no value is set for the option $key, return the default value by calling getDefault(). If a value is set, return that value.

Parameters:
$key [string]: The name of the option/default
Returns:
[mixed]: The value of the option

PageRender2::getPage (  ) 

Get the SPage object.

Return the SPage object that buffers all the page content for this PR2 instance.

Returns:
[SPage]: The page object

PageRender2::getPageTemplate (  ) 

Get the active SPageTemplate for this PR2 instance.

Get the SPageTemplate object or subclass that represents the current page template for this PR2 instance.

Returns:
[SPageTemplate]: The page template object

PageRender2::includeCSS ( filename,
root = '' 
)

Include a link to a CSS file in the page head.

Add a rel tag linking to a javascript file. By default, use the passed $filename as the complete path to the file. Or use one of the following values passed for $root as the base path:

  • ProjectCSS (this project's CSS dir, i.e., project/public/css)
  • DefaultSkin (the default skin dir, i.e., common/ui/default/css)
  • CustomSkin (the custom skin selected by this project, i.e., common/ui/customSkin/css)
Parameters:
$filename [string]: The path to the CSS file
$root [string]: The root of the path: blank, ProjectCSS, DefaultSkin, or CustomSkin

PageRender2::includeJS ( filename,
root = '' 
)

Include a link to a javascript file in the page head.

Add a script tag linking to a javascript file. By default, use the passed $filename as the complete path to the file. Or use one of the following values passed for $root as the base path:

  • ProjectJS (this project's JS dir, i.e., project/public/js)
  • DefaultSkin (the default skin dir, i.e., common/ui/default/js)
  • CustomSkin (the custom skin selected by this project, i.e., common/ui/customSkin/js)
Parameters:
$filename [string]: The path to the javascript file
$root [string]: The root of the path: blank, ProjectJS, DefaultSkin, or CustomSkin

PageRender2::load ( input,
options = array(),
name = "" 
)

Load content into the page using a translator.

Use a translator to take input content (in any format for which there is a translator), translate it to the target output format, and store it in a slot in the page buffer.

By default, a load command appends its output to the Main slot.

Additional options can be specified in the $options array to change the destination slot or the input or output format. The load can also be given a name for later access.

Parameters:
$input [mixed]: The input content to be translated (a string or object)
$options [array]: Overrides to the defaults for this particular load
$name [string]: The name of the load (deprecated)
Returns:
[boolean]: True on success, false on failure

PageRender2::loadCSS ( css  ) 

Load literal CSS to the ExtraCSS slot.

Load literal CSS into the ExtraCSS slot in the head of the page

Parameters:
$css [string]: The literal CSS

PageRender2::loadJS ( js,
slot = 'ExtraJS' 
)

Load literal javascript to the ExtraJS slot (or another slot).

Load literal javascript into a slot in the (head of the) page

Parameters:
$js [string]: The literal javascript code
$slot [string]: The name of the slot, or blank to use the ExtraJS slot

PageRender2::rebaseCserdUrls ( enable = true,
projectUrl = false 
)

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$enable [TYPE]: DESCRIPTION
$projectUrl [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::render (  ) 

Render the page content, store it in the SPage buffer.

Get the instance of our page layout class, and tell it to layout()

Returns:
[boolean]: True on success, false on failure

PageRender2::renderPrint ( format = "html"  ) 

Render the page to the page buffer, then print it out.

INSERT FULL DESCRIPTION HERE

Parameters:
$format [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::runTestSuite ( extras = null  )  [protected]

Build a report to tell a user agent whether the page has errors.

Returns:
[array]: All test suite values from PR2, as an array

PageRender2::setClass ( key,
value 
)

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$key [TYPE]: DESCRIPTION
$value [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::setOption ( key,
value 
)

Set a value for an option (to override a default value).

Override a default value in PR2, such as what translator is used for a given input type.

Parameters:
$key [string]: The name of the option/default
$value [mixed]: The new value for the option

PageRender2::setToolkitTheme ( theme  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Parameters:
$theme [TYPE]: DESCRIPTION
Returns:
[TYPE]: RETURN DESCRIPTION

PageRender2::useCachedVersion ( lifetime = ""  ) 

Tell PR2 to use the cached version of a page instead of rendering each time.

Call this function before calling renderPrint(), typically at the top of your controller.

If this function finds that there is a cache existing within the cache lifetime, it will print that cache to the screen immediately, and exit bypassing the rest of the controller.

Pass in the $lifetime variable to specify for how many seconds the page cache should be valid before PR2 needs to call renderPrint() again to generate a new version of the page.

Parameters:
$lifetime [int]: The number of seconds for which the cache should be valid
Returns:
[bool]: Return false on failure.


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:02:29 2010 for Common by  doxygen 1.5.6