Class Crafty_Block

Description

Crafty_Block class implementation

Any crafty block will get it's own Crafty_Block instance with individual $content.
Each time the block is used static it will be cloned at compile time from Crafty_Compiler::$blocks and compiled itsself.

Located in /crafty/Crafty_Block.class.php (line 55)


	
			
Variable Summary
Method Summary
Crafty_Block __construct (string $name, crafty_compiler $compiler)
void compile ()
void compileElement (mixed $element)
string compileType (array $element)
string getVarPrefix ([string $suffix = ''])
void load (string $raw_content)
mixed varToStatic (array $param, [boolean $add_quotes = TRUE], [boolean $parse_array = FALSE])
Variables
Crafty_Compiler $compiler (line 75)

Object handle of the Crafty_Compiler for this block.

  • access: public
array $content = array() (line 68)

Stores all data the block needs to compile

This is a list of object handles of Crafty_Core_* objects and corresponding datasets or other Crafty_Block instances.
Since this will be compiled recursively by compileElement() it can be a complex "tree" of arrays.

  • access: public
string $filename = '' (line 94)

Filename where the block is defined

  • access: public
bool $is_external = FALSE (line 132)

Defines if a blocks content is stored in an external file

  • access: public
int $line_cont = -1 (line 108)

Line number of the content begining in the definition file

  • access: public
int $line_decl = -1 (line 101)

Line number of the block declaration in the definition file

  • access: public
string $name (line 87)

Stores the the name of the block or it's linearized adresses

The original parsed blocks will have it's name in here and the cloned ones for static compilation will have it's linearized adresses. For variable blocks that are compiled into separate files the blocks of Crafty_Compiler::$blocks will get a variable name/adress using $p.

  • access: public
string $raw_content = '' (line 115)

The raw content of the block used for error tracing

  • access: public
string $template_path (line 125)

The path to the template file that generated this block

Set by the constructor using Crafty_Compiler::template_path that is reset by recursion

  • access: public
Methods
Constructor __construct (line 145)

Initializes a Crafty_Block instance

The constructor intializes a Crafty_Block instance and sets the $name aswell as the $compiler.

  • access: public
Crafty_Block __construct (string $name, crafty_compiler $compiler)
  • string $name: Name of the current block
  • Crafty_Compiler $compiler: Crafty_Compiler object that created this Block
compile (line 158)

Compiles a block

This method will compile a block compiling all elements of the $content.

  • access: public
void compile ()
compileElement (line 180)

Recursively compile an Element

In case the Element is a Crafty_Block object this method will use its compile() method.
In case it is an array with a "core" index it writes the returned data of compileType() in the binary template file.
In case it is a different array it will recursively handle the elements.
Otherwise it assumes that the Element a string or something castable as string and writes it in the compiled templates. The last way however is not currently used.

  • access: protected
void compileElement (mixed $element)
  • mixed $element
compileType (line 207)

Compiles a set of a core handler and a dataset

This method makes use of the Crafty_Core::compile().

  • return: Binary data
  • access: protected
string compileType (array $element)
  • array $element: Element to compile
getVarPrefix (line 310)

Returns the linearized adress of the current block

This method makes use of the $name but strips of the "main." prefix.
If a suffix is set this will be conatenated to the adress path. Useful for getting the adress of a subelement of the current block.

  • return: Linearized adress of the current block
  • access: public
string getVarPrefix ([string $suffix = ''])
  • string $suffix: [optional,default=''] Element suffix
load (line 232)

Loads a raw blow of CraftyHTML

First this method replaces the preparse needles with the preparse replacements. Then it will try to match each core pattern. On success it will hand over the results to Crafty_Core::pregCallback().
All parts of the CraftyHTML that are not matched by any core will be handed to a Crafty_Core_String object.

  • access: public
void load (string $raw_content)
  • string $raw_content
varToStatic (line 332)

Convert a $data entry to snippet that can be written in our compiled template.

If $add_quotes is TRUE the snippet can be used just like echo <snippet>;
If $add_quotes is FALSE the snippet can be used inside single quoted strings.
If $parse_array is true this will be done on all elements of the $param['array'] array and an array of snippets will be returned.

  • access: public
mixed varToStatic (array $param, [boolean $add_quotes = TRUE], [boolean $parse_array = FALSE])
  • array $param
  • boolean $add_quotes: [default=TRUE]
  • boolean $parse_array: [default=FALSE]

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