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.

Public Attributes

const XML_PARSE_ERROR

Protected Member Functions

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

Protected Attributes

 $inputs
 $options
 $page

Private Member Functions

 getHelper ($array, $key)
 Help other get methods fetch their values.


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

Definition at line 19 of file PageRender2.php5.


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.)

Definition at line 44 of file PageRender2.php5.


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())

Definition at line 308 of file PageRender2.php5.

References $options, and 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

Definition at line 792 of file PageRender2.php5.

References SCacheManager::clearPageCache().

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

Definition at line 689 of file PageRender2.php5.

References getPage().

Referenced by flashAndExit().

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

Definition at line 701 of file PageRender2.php5.

References flash(), and renderPrint().

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

Definition at line 718 of file PageRender2.php5.

References SWATFunctions::redirect().

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

Definition at line 661 of file PageRender2.php5.

Referenced by renderPrint().

PageRender2::getClass ( key  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

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

Definition at line 89 of file PageRender2.php5.

References getHelper().

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

Definition at line 119 of file PageRender2.php5.

References SObject::setPrettyError().

Referenced by getLayout(), getPageTemplate(), load(), and render().

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

Definition at line 70 of file PageRender2.php5.

Referenced by getOption().

PageRender2::getHelper ( array,
key 
) [private]

Help other get methods fetch their values.

For internal use only.

Definition at line 209 of file PageRender2.php5.

Referenced by getClass().

PageRender2::getInput ( key  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

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

Definition at line 222 of file PageRender2.php5.

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

Definition at line 246 of file PageRender2.php5.

References getClassInstance(), and getOption().

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

Definition at line 142 of file PageRender2.php5.

References getDefault().

Referenced by getLayout(), getPageTemplate(), render(), and renderPrint().

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

Definition at line 200 of file PageRender2.php5.

Referenced by flash(), renderPrint(), and runTestSuite().

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

Definition at line 234 of file PageRender2.php5.

References getClassInstance(), and getOption().

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

Definition at line 359 of file PageRender2.php5.

References SPath::getRelPath(), and load().

Referenced by load().

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

Definition at line 327 of file PageRender2.php5.

References SPath::getRelPath(), and load().

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

Definition at line 421 of file PageRender2.php5.

References $options, getClassInstance(), SObject::getErrorFrom(), SObject::getWarningFrom(), SObject::hasError(), includeCSS(), and SObject::setPrettyError().

Referenced by add(), includeCSS(), includeJS(), loadCSS(), loadJS(), and renderPrint().

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

Definition at line 401 of file PageRender2.php5.

References load().

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

Definition at line 390 of file PageRender2.php5.

References load().

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

Definition at line 180 of file PageRender2.php5.

References SConfig::setOption().

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

Definition at line 516 of file PageRender2.php5.

References getClassInstance(), getOption(), and SObject::setPrettyError().

Referenced by renderPrint().

PageRender2::renderPrint ( format = "html"  ) 

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

Definition at line 730 of file PageRender2.php5.

References SConfig::getDefault(), and getPage().

PageRender2::setClass ( key,
value 
)

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

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

Definition at line 102 of file PageRender2.php5.

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

Definition at line 155 of file PageRender2.php5.

Referenced by renderPrint(), and useCachedVersion().

PageRender2::setToolkitTheme ( theme  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

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

Definition at line 167 of file PageRender2.php5.

References Toolkit::setDefaultTheme().

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.

Definition at line 758 of file PageRender2.php5.

References SCacheManager::checkPageCache(), SConfig::getDefault(), STestReporter::register(), and setOption().


Member Data Documentation

PageRender2::$inputs [protected]

For internal use only.

An array of all the inputs for the page (includes XML resources, HTML resources, media, etc...)

Definition at line 29 of file PageRender2.php5.

PageRender2::$options [protected]

For internal use only.

Options stores the user-defined options, wereas defaults stores the program-defined default values for the options.

Definition at line 25 of file PageRender2.php5.

Referenced by add(), and load().

PageRender2::$page [protected]

For internal use only.

The current page is stored in this object

Definition at line 22 of file PageRender2.php5.

Referenced by renderPrint().

For internal use only.

Indicates there was a parse with XML???

Definition at line 36 of file PageRender2.php5.


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

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