Class Crafty_Core

Description

Crafty_Core abstract class

The Crafty_Core class is a parent class for all Crafty_Core_* classes. It features helpful preg tools for parameter parsing etc., so the extending class cann concentrate on the individual important things. If you just want to write templates you will never need to care about this class. It's children are only used by the compiler.

Located in /crafty/core/Crafty_Core.class.php (line 56)


	
			
Direct descendents
Class Description
Crafty_Core_Block Crafty_Core_Block class implementation
Crafty_Core_Blocklist Crafty_Core_Blocklist class implementation
Crafty_Core_Comment Crafty_Core_Comment class implementation
Crafty_Core_Formelement Crafty_Core_Formelement class implementation
Crafty_Core_Link Crafty_Core_Link class implementation
Crafty_Core_Now Crafty_Core_Now class implementation
Crafty_Core_String Crafty_Core_String class implementation
Crafty_Core_Variable Crafty_Core_Variable class implementation
Crafty_Core_Define Crafty_Core_Define class implementation
Crafty_Core_Require Crafty_Core_Require class implementation
Variable Summary
Method Summary
Crafty_Core __construct (Crafty_Compiler $compiler)
string compile (array $data, Crafty_Block $block)
mixed getPattern ()
array pregCallback (array $matches)
string randomVarname ([boolean $adddollar = TRUE])
void _defineCheck (array &$data, string $prefix)
array _pregCallbackArray (array $data)
boolean _setPattern ([string $pattern = ''], [boolean $add_core_separator = TRUE], [boolean $add_core_delimiters = TRUE], [string $modifiers = ''], [boolean $add_preg_delimiter = TRUE])
Variables
string $name = '"undefined Crafty_Core"' (line 96)

The name of this Crafty_Core_<name>

This one is hardly used (except for error messages) and automatically generated by the constructor.

  • access: public
Crafty_Compiler $_compiler (line 76)

Compiler object handle

Object handle of the Crafty_Compiler that spawned this core. This one is especially helpful to get the config.

  • access: protected
Crafty_Config $_config (line 86)

Configuration object handle

The object handle of the Core specific xml configuration part. The constructor gets this one from the compiler.

  • access: protected
string $_pattern (line 66)

Preg pattern to capture the used cores

_setPattern() helps to create this preg.

  • access: protected
Methods
Constructor __construct (line 106)

Abstract constructor

By calling this abstract parent constructor a Crafty_Core_* child gets the $compiler and $_config set correctly.

  • access: public
Crafty_Core __construct (Crafty_Compiler $compiler)

Redefined in descendants as:
compile (line 134)

Compile this core to binary code

Any Crafty_Core_* class must have an own compile function. This function will get a complex $data array and a Crafty_Block.
Using that intput it will return a string containing php code that will be written in the compiled temmplate file.

  • return: Binary template data
  • access: public
  • abstract:
string compile (array $data, Crafty_Block $block)
  • array $data: Parameter array
  • Crafty_Block $block: The block that contains this core

Redefined in descendants as:
getPattern (line 196)

Returns the current Crafty_Core::$_pattern

If the pattern is empty FALSE will be returned and the core will not capture with preg_match_all.

  • access: public
mixed getPattern ()
pregCallback (line 236)

Parses parameters of a core

This method takes a preg result set ($matches) and parses it for parameters using once again very complex perl regular expressions.
It also replaces the preparser replacements with their final values.
It also takes care of security and prepares for usage in single quoted strings.
Finally it replaces the configuration variables using _defineCheck().

array pregCallback (array $matches)
randomVarname (line 349)

Generates a random variable name

Such a random variable name will be used for temporary variables in the (binary) php code. If $adddollar is TRUE the dollar for php variables will be added, otherwise it will be left as a random string.

  • return: Random variable name.
  • access: public
string randomVarname ([boolean $adddollar = TRUE])
  • boolean $adddollar: [optional,default=TRUE] Whether or not to add the '$' PHP variable prefix.
_defineCheck (line 373)

Helper function for pregCallback()

Checks if the parameter $data contains defined variables and replaces them if that is the case.

  • access: protected
void _defineCheck (array &$data, string $prefix)
  • array $data: Reference to the parameter data array
  • string $prefix: The variable prefix
_pregCallbackArray (line 214)

Returns an array to save in Crafty_Block::$content

This method is called by pregCallback() and will return an array of the parameter $data and the object handle of the core itsself.

array _pregCallbackArray (array $data)
  • array $data: Data array
_setPattern (line 150)

Construct a preg pattern

If the configuration part for the core is complete this method can be called without any arguments. You should only use the parameters if you know what you are doing.

  • return: State of success
  • access: protected
boolean _setPattern ([string $pattern = ''], [boolean $add_core_separator = TRUE], [boolean $add_core_delimiters = TRUE], [string $modifiers = ''], [boolean $add_preg_delimiter = TRUE])
  • string $pattern: [optional, default='']
  • boolean $add_core_separator: [optional, default=TRUE]
  • boolean $add_core_delimiters: [optional, default=TRUE]
  • string $modifiers: [optional, default='']
  • boolean $add_preg_delimiter: [optional, default=TRUE]

Documentation generated on Sat, 19 Feb 2005 01:43:42 +0100 by phpDocumentor 1.3.0RC3