Class QPTPL

(line 31)

Description


Located in File: /src/QueryPath/Extension/QPTPL.php

QPTPL is a template library for QueryPath.

The QPTPL extension provides template tools that can be used in conjunction with QueryPath.

There are two basic modes in which this tool operates. Both merge data into a pure HTML template. Both base their insertions on classes and IDs in the HTML data. Where they differ is in the kind of data merged into the template.

One mode takes array data and does a deep (recursive) merge into the template. It can be used for simple substitutions, but it can also be used to loop through "rows" of data and create tables.

The second mode takes a classed object and introspects that object to find out what CSS classes it is capable of filling. This is one way of bridging an object model and QueryPath data.

The unit tests are a good place for documentation, as is the QueryPath webste.



Class Variables

Summary:
mixed $qp

$qp (line 32)

Data type : mixed

  • access: - protected

Class Constants

Summary:

Method Detail

Summary:
QPTPL __construct (QueryPath $qp)
Boolean isAssoc (array $array)
string method2class (string $mname)
QueryPath tpl (mixed $template, mixed $object, [array $options = array()])
QueryPath tplAll (mixed $template, array $objects, [array $options = array()])
void tplArrayR ( $qp,  $array, [ $options = NULL])
void tplObject ( $tqp,  $object, [ $options = array()])

Constructor __construct (line 33)

QPTPL __construct( QueryPath $qp)


Implementation of:
QueryPathExtension::__construct()

Parameters

Info

  • access - public

Method isAssoc (line 238)

Boolean isAssoc( array $array)

Check whether an array is associative.

If the keys of the array are not consecutive integers starting with 0, this will return false.

Parameters

  • array $array: The array to test.

Info

  • return - TRUE if this is an associative array, FALSE otherwise.
  • access - public

Method method2class (line 252)

string method2class( string $mname)

Convert a function name to a CSS class selector (e.g. myFunc becomes '.myFunc').

Parameters

  • string $mname: Method name.

Info

  • return - CSS 3 Class Selector.
  • access - protected

Method tpl (line 71)

QueryPath tpl( mixed $template, mixed $object, [array $options = array()])

Apply a template to an object and then insert the results.

This takes a template (an arbitrary fragment of XML/HTML) and an object or array and inserts the contents of the object into the template. The template is then appended to all of the nodes in the current list.

Note that the data in the object is *not* escaped before it is merged into the template. For that reason, an object can return markup (as long as it is well-formed).

Parameters

  • mixed $template: The template. It can be of any of the types that qp() supports natively. Typically it is a string of XML/HTML.
  • mixed $object: Either an object or an associative array.
    • In the case where the parameter
    is an object, this will introspect the object, looking for getters (a la Java bean behavior). It will then search the document for CSS classes that match the method name. The function is then executed and its contents inserted into the document. (If the function returns NULL, nothing is inserted.)
    • In the case where the paramter is an associative array, the function will
    look through the template for CSS classes that match the keys of the array. When an array key is found, the array value is inserted into the DOM as a child of the currently matched element(s).
  • array $options: The options for this function. Valid options are:
    • <None defined yet>

Info

  • return - Returns a QueryPath object with all of the changes from the template applied into the QueryPath elements.
  • see - QueryPath::append()
  • access - public

Method tplAll (line 102)

QueryPath tplAll( mixed $template, array $objects, [array $options = array()])

Given one template, do substitutions for all objects.

Using this method, one template can be populated from a variety of sources. That one template is then appended to the QueryPath object.

Parameters

  • mixed $template: The template. It can be of any of the types that qp() supports natively. Typically it is a string of XML/HTML.
  • array $objects: An indexed array containing a list of objects or arrays (See tpl()) that will be merged into the template.
  • array $options: An array of options. See tpl() for a list.

Info

  • return - Returns the QueryPath object.
  • see - QPTPL::tpl()
  • access - public

Method tplArrayR (line 189)

void tplArrayR( $qp, $array, [ $options = NULL])

Recursively merge array data into a template.

Parameters

  • $qp:
  • $array:
  • $options:

Info

  • access - public

Method tplObject (line 167)

void tplObject( $tqp, $object, [ $options = array()])

Introspect objects to map their functions to CSS classes in a template.

Parameters

  • $tqp:
  • $object:
  • $options:

Info

  • access - protected

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Sun, 25 Jul 2010 16:09:06 -0500 by phpDocumentor 1.4.3