Class plainTemplates

(line 11)

Description


Located in File: /plainTemplates.php

Class for automated manipulation of plain HTML pages as advanced templates with _(phpQuery).


Class Variables

Summary:
static string $cacheDir
static mixed $cacheTimeout
static array $dataSelectors
static mixed $debug
static string $fixWebRoot
static bool $print
static mixed $replace
static string $templatesDir
static array $tidyConfig
static bool $useTidy
static mixed $_template

static $cacheDir = './cache/' (line 23)

Data type : string

Path to direcotry where cacheed templates will be stored.
  • see: - self::$cacheTimeout
  • access: - public

static $cacheTimeout = false (line 49)

Data type : mixed

Timeout for cached templates in minutes.

Generally uneeded because of checking templates modification time. False (default) means no timeout.

  • see: - self::$cache
  • see: - self::$cacheDir
  • access: - public

static $dataSelectors = array(
'wrapper' => '', // CSS selector for wrapper. Wrapper is an elements that wraps the container and optionally other elements (like title).
'container' => 'ul', // CSS selector for loop's container. Relative to wrapper.
'row' => 'li', // CSS selector for row. Relative to container.
'field' => '.%s', // CSS selector for row field. Relative to row. Use %s as field name.
'inheritSelectors' => false, // TODO; inherits parent selectors, only for children
'removeFieldClasses' => false, // Removes field's class from matched field tag.
)
(line 79)

Data type : array

  • access: - public

static $debug = false (line 17)

Data type : mixed

Turns on/off debug. Includes phpQuery's one.
  • see: - phpQuery::$debug
  • access: - public

static $fixWebRoot = '' (line 92)

Data type : string

Fixes paths to CSS, JS and image files.
  • todo: - Dont update external links.
  • access: - public

static $monitorCodeModification = true (line 35)

Data type : bool

Checks if source code file has been modified.

Use it only on developement enviroment as it runs debug_backtrace() every time.

  • access: - public

static $monitorTemplateModification = true (line 29)

Data type : bool

Checks if source template file exists and if it has been modified.

Can be turned off for performance reasons on production enviroment.

  • access: - public

static $print = true (line 54)

Data type : bool

If true (default) prints template result to buffer, instead of returning it's string (optional).
  • access: - public

static $replace = array(
'<php>' => '<?php ',
'</php>' => ' ?>',
// TODO: rewrite those below to regexp searching only inside php tags, but not in string, maybe with support of "{$nestedVars} in strings"
'%7B' => '{',
'%24' => '$',
'%7D' => '}',
)
(line 93)

Data type : mixed

  • access: - protected

static $templatesDir = '' (line 40)

Data type : string

Path prepended to template names.
  • access: - public

static $tidyConfig = array(
'indent' => true,
'indent-spaces' => 4,
'wrap' => false,
'show-body-only' => 'yes',
'merge-divs' => false,
'new-blocklevel-tags' => 'php',
)
(line 68)

Data type : array

Config fo Tidy.

static $useTidy = false (line 62)

Data type : bool

Use HTML Tidy for pretty output (if avaible).

Tidy is included with every PHP5 installation, but it has be manually activated into php.ini. However there are several issues with Tidy at this time.

  • todo: - Strip out HTML/BODY if it's soudlnt be in the template (something what show-body-only should do).
  • access: - public

static $_template = null (line 101)

Data type : mixed

  • access: - protected

Class Constants

Summary:

Method Detail

Summary:
static void checkCache ()
static void cleanCacheName ( $name)
static string|false createTemplate (string|array $source, [array $data = array()], [mixed $callback = null], [ $templateName = null], string $cacheName)
static void getCachePaths ( $templateName, [ $cacheDir = null])
static string|false getTemplate ( $templateName,  $templatePath, [ $cacheDir = null])
static void includePhpQuery ()
static void insertData ( $data, [ $selectors = array()], [ $suffix = 'Row'])
static void insertRow ( $selectors,  $row,  $_row,  $varName, [ $prefixes = array('','')])
static void isPhpQuery ( $var)
static void mapDepends ( $file)
static array parseIncludes (phpQueryClass $_)
static void PXTtoPHP ( $PXT)
static phpQueryClass removeIncludes (phpQueryClass $_)
static string|false saveTemplate (phpQueryClass $_, string $templatePath, [string $templateName = null], [array $dependencies = array()], [string $cacheDir = null], [bool $unloadDocument = true])
static void srcFilePath ()
int clearCache ([string $search = '*'])
void runCallback ( $_,  $callback)

Static Method checkCache (line 466)

void checkCache( )

Info

  • access - protected

Static Method cleanCacheName (line 493)

void cleanCacheName( $name)

Parameters

  • $name:

Info

  • access - protected

Static Method createTemplate (line 122)

string|false createTemplate( string|array $source, [array $data = array()], [mixed $callback = null], [ $templateName = null], string $cacheName)

Creates template from plain HTML file or certain part of it (with $source[1]).

If You want to insert DB data into template use $data and $dataSelectors. You can apply callback on result with $callback.

Parameters

  • string|array $source: Template file path as string or as [0] if array given. Relative to self::$templatesDir. $source[1] is CSS selector that limits template to part(s) matching the selector. Limiting template changes result's stack, except when $data present.
  • array $data: Optional. Containing var name (on [0]), value (on [1]) and selectors (on [2]). Name is needed to preserve scope. Selectors are inherited from plainTemplates::$dataSelectors. Data insertion changes result's stack to match place(s) where data has been inserted. If you need another state of the result's stack - change it manually in callback. $data[2] can be a string, then it's used as 'wrapper'.
  • mixed $callback: Optional. Can be result of create_function(), function name, array with object reference in [0] and method name in [1] or array with class name in [0] and static method name in [1]. Callback called after template parsing. Can return phpQueryClass object to change stack.
  • string $cacheName: Optional. Needed when You want to build two templates with same selectors from one HTML. Also helps finding template inside cache dir.
  • $templateName:

Info

  • return - Returns include path or false in case of error.
  • access - public

Static Method getCachePaths (line 481)

void getCachePaths( $templateName, [ $cacheDir = null])

Parameters

  • $templateName:
  • $cacheDir:

Info

  • access - protected

Static Method getTemplate (line 171)

string|false getTemplate( $templateName, $templatePath, [ $cacheDir = null])

Returns cached template's path for inclusion.

Returns false if cache isn't up-to-date.

Parameters

  • $templateName:
  • $templatePath:
  • $cacheDir:

Info

  • access - public

Static Method includePhpQuery (line 527)

void includePhpQuery( )

Info

  • access - protected

Static Method insertData (line 365)

void insertData( $data, [ $selectors = array()], [ $suffix = 'Row'])

Parameters

  • $data:
  • $selectors:
  • $suffix:

Info

  • access - protected

Static Method insertRow (line 420)

void insertRow( $selectors, $row, $_row, $varName, [ $prefixes = array('','')])

Parameters

  • $selectors:
  • $row:
  • $_row:
  • $varName:
  • $prefixes:

Info

  • todo - support defining field selectors per field
  • todo - support empty field selectors (insert field data directly inside row selector
  • access - protected

Static Method isPhpQuery (line 524)

void isPhpQuery( $var)

Parameters

  • $var:

Info

  • access - protected

Static Method mapDepends (line 354)

void mapDepends( $file)

Parameters

  • $file:

Info

  • access - protected

Static Method parseIncludes (line 290)

array parseIncludes( phpQueryClass $_)

Fetches included templates content into parsed one.

Parameters

  • phpQueryClass $_:

Info

  • return - Array of dependencies.
  • access - public

Static Method PXTtoPHP (line 496)

void PXTtoPHP( $PXT)

Parameters

  • $PXT:

Info

  • access - protected

Static Method removeIncludes (line 324)

phpQueryClass removeIncludes( phpQueryClass $_)

Removes included templates from parsed one.

Parameters

  • phpQueryClass $_:

Info

  • access - public

Static Method saveTemplate (line 223)

string|false saveTemplate( phpQueryClass $_, string $templatePath, [string $templateName = null], [array $dependencies = array()], [string $cacheDir = null], [bool $unloadDocument = true])

Creates new template and returns it's path.

If You want to use self::$fixWebRoot You have to pass phpQueryClass object directly. CAUTION: this method will call unload() on passed phpQuery object, so You cant use it futher. Use $unloadDocument to avoid this.

Parameters

  • phpQueryClass $_: String from object will be fetched with htmlWithTag(), so take care of proper stack.
  • string $templatePath:
  • string $templateName:
  • array $dependencies:
  • string $cacheDir:
  • bool $unloadDocument:

Info

  • access - public

Static Method srcFilePath (line 357)

void srcFilePath( )

Info

  • access - protected

Method clearCache (line 335)

int clearCache( [string $search = '*'])

Clears cache folder. Can be limited to files containing $search in names.

Returns number of deleted files.

Parameters

  • string $search: Optional. Search pattern, accepts wildcard. @see http://php.net/glob

Info

  • access - public

Method runCallback (line 345)

void runCallback( $_, $callback)

Parameters

  • $_:
  • $callback:

Info

  • access - protected

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Mon, 30 Jul 2007 16:33:59 +0200 by phpDocumentor 1.3.2