Class Nexista_Flow

Description

This class Nexista_handles I/O between sitemap nodes (files) and will output an xml tree at the end if requested by the XSLT handler.

One of the core features of Nexista is the Flow concept. Flow represents the wiring so to speak of the application. It controls all data i/o from scripts, databases, get/post, etc... And allows for a unified interface to all these variables as well as permits "smart" access to the data. Flow data is eventually used to generate XML which can be used in subsequent XSL transformations.

Flow data handling is transparent to the developer. The only necessary thing to understand is how to call Flow variables and what data can be accessed in this manner.

The flow class Nexista_is an extension of the "PHP5 and thus provides all the standard XML functionality as well as a few additional methods.

At startup, Flow is initialized with a number of special variables. This data is user writeable so actions and other modifiers can be used. By default, Flow imports these variables as they are. A user specified handler function can be called to control the import process - see Flow::registerImportHandler in API docs.

_get

  • Initialized with a copy of $_GET data. All incoming GET data
will be found there (ex: nx_get/nid would represent the current requested gate
  • $_GET['nid']). _post- Initialized with a copy of $_POST data. All incoming POST data
will be found there (ex: nx_post/submit could be used to see if a form has been submitted - $_POST['submit']). This data is user writeable so actions and other modifiers can be used. _files
  • Initialized with a copy of $_FILES data. _globals - Initialized with a copy of $GLOBALS data. _session- Initialized with a copy of $_SESSION data.
Flow is user writeable and developers are free to organize their data as they see fit. Certain actions such as queries and validator will write their data to flow based on their name. Ex: a select query with the name 'article' will return its data as:
  1. <article>
  2.       <title>Article One</title>
  3.       <data>The text goes here</data>
  4.  </article>
  5.  <article>
  6.       <title>Article Two</title>
  7.       <data>some stuff here as well</data>
  8.  </article>
  9.       ...and so on for each row found
use &lt;map:debug xml_dump="true"/&gt; after a validator or query to analyze this data.

Located in /kernel/flow.php (line 69)


	
			
Variable Summary
 string $array_type
 DOMDocument $flowDocument
 DOMElement $root
 string $xmlStream
Method Summary
 static boolean add (mixed $node, [mixed $value = null], [object (optional) $root = false])
 static void delete (object reference $node)
 static object DOMNodeList, find (string $exp, [object (optional) $parent = null])
 static mixed get (object a $node, [string $array_type = null])
 static mixed getByPath (string $path, [ $array_type = null])
 static void registerImportHandler (mixed $handler)
 static object class singleton ()
 string getXmlStream ()
 void init ()
 string outputXml ( $node)
 void writeXmlStream (string $data)
Variables
string $array_type (line 105)

Array type

  • access: public
DOMDocument $flowDocument (line 88)

Flow DOM document object

  • access: public
DOMElement $root (line 97)

Flow DOM document root node

  • access: public
string $xmlStream (line 130)

Main xml output data container.

stream data holder. Is an xml string that will be eventually outputed to any xml receiving module such as a xsl transformer. This is the only source of display content. Some modules such as raw xml files, will output direclty to stream, while others, such as script modules, will merge all their dynamic data at the end to stream using write()

  • access: public
Methods
static add (line 421)

Creates and appends one or more children elements

This method is a shortcut to the createElement, appendChild sequence and can also accept associative arrays of any depth

There are a few ways to call this method:

  • Flow::add('name', 'value'); would result in a new child at the root level
called 'name' with a value of 'value'.
  • Flow::add(array('name1'=>'value1', 'name2'=>'value2')); would result in two
new children at root level (name1 and name2) with respective values
  • Flow:add('name', array('blue','red')); would result in 2 new nodes at root
level of name 'name' with values of 'blue' and 'red' respectively.
  • Flow::add('name', array('sub1'=> 'blue','sub2'=>'red')); would result in a
new node of name 'name' at rool level, which contains 2 children (sub1 and sub2) each with the values of blue and red respectively.

Note that multi level arrays can be used.

  • return: success. Usual fail reason is non valid XML names (numeric arrays)
  • access: public
boolean add (mixed $node, [mixed $value = null], [object (optional) $root = false])
  • mixed $node: a string for a single child or associative array of child->values
  • mixed $value: (optional) if a string is passed with $node, this is the value. If an numerical array is passed, it represents the multiple children of type $node.
  • object (optional) $root: reference to a DOMElement child if none is passed, root is assumed
static delete (line 292)

Deletes a flow variable and all its content

  • access: public
void delete (object reference $node)
  • object reference $node: to flow var to delete
static find (line 219)

Finds a flow var using an xpath query

  • return: empty if nothing found
  • access: public
object DOMNodeList, find (string $exp, [object (optional) $parent = null])
  • string $exp: xpath expression
  • object (optional) $parent: reference to parent node for relative searches
static get (line 242)

Returns the value of a flow variable

If the value of a variable is CDATA, it will return this. If the variable contains children nodes, it will return a recursive array

  • return: string or array of variable contents
  • access: public
mixed get (object a $node, [string $array_type = null])
  • object a $node: valid DOMElement reference
  • string $array_type: for single values: associative or numeric array?
static getByPath (line 316)

Returns the value of a flow variable(s) given an xpath query

This is a wrapper for a joined find/get item query. If multiple items are found, it will only return the first one

  • return: value of first found variable, or an array if multiple matches, or null if no matches
  • access: public
mixed getByPath (string $path, [ $array_type = null])
  • string $path: an xpath query
  • $array_type
static registerImportHandler (line 484)

Registers a function to be called on init

This function will be called when Flow inits and imports things such as the $_GET, $_POST datasets. This permits the developer to perform actions before assignement to flow such as stripping tags, etc... This method will be given an array and needs to return an array.

  • access: public
void registerImportHandler (mixed $handler)
  • mixed $handler: a function or an array of class=>method
static singleton (line 371)

Returns a class Nexista_singleton.

  • return: Nexista_singleton instance
  • access: public
object class singleton ()
getXmlStream (line 359)

Returns stream data

  • return: data
  • access: public
string getXmlStream ()
init (line 138)

Initialize flow with basic data (request,session)

  • access: public
void init ()
outputXml (line 388)

Outputs flow as xml

  • return: xml
  • access: public
string outputXml ( $node)
  • $node
writeXmlStream (line 347)

Writes string to stream

  • access: public
void writeXmlStream (string $data)
  • string $data: data to write to XmlStream

Documentation generated on Tue, 11 Mar 2008 23:23:01 -0400 for Nexista 0.2.0