Class

DefaultTemplateData

Package: IO\Template\data Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Benoit SAUTEL ben.popeye@phpboost.com Version: PHPBoost 5.2 - last update: 2018 09 14 Since: PHPBoost 3.0 - 2010 02 19 Contributor: Julien BRISWALTER j1.seth@phpboost.com Contributor: Arnaud GENET elenwii@phpboost.com Located at: io/template/data/DefaultTemplateData.class.php

This class is a default implementation of the TemplateData interface.

DefaultTemplateData implements TemplateData
Methods summary
public
# enable_strict_mode( )

Enables the strict mode. If a variable that does not exist in the object is requested, then an exception will be raised.

public
# disable_strict_mode( )

Disables the strict mode. If a variable that does not exist in the object is requested, then an empty value will be returned.

public
# auto_load_frequent_vars( )

Loads the most common vars which are useful in the whole PHPBoost templates. The variables are:

  • THEME the theme used by the current user
  • LANG the lang used by the current user
  • IS_USER_CONNECTED tells whether the user is connected (member, moderator or administrator)
  • IS_ADMIN tells whether the user is administrator
  • IS_MODERATOR tells whether the user is moderator
  • PATH_TO_ROOT is the path which starts from the domain root (in HTTP context) and goes to the PHPBoost root. For instance if PHPBoost is installed at www.example.com/directory/, its value will be /directory.
  • PHP_PATH_TO_ROOT is the server side path, it's the path which goes to the PHPBoost's root.
  • TOKEN is the CSRF protection token. It's to use in the critical actions to show that the user really intended doing the action
  • REWRITED_SCRIPT the current url
public
# put( $key, $value )

Assigns the value

$value

to the template variable of name

$key
public
# put_all( array $vars )

Assigns template variables. It could be simple variables, loop or subtemplates.

public
# assign_block_vars( string $block_name, array $array_vars, array $subtemplates = array() )

Assigns a template block. A block represents a loop and has a name which be used in your template file to indicate which loop you want to browse. To know what syntax to use to browse a loop, see the class description, there are examples.

public mixed[]
# get_block( string $blockname )

Returns the block $blockname in the template block list

public mixed[]
# get_block_from_list( string $blockname, mixed[] $parent_block )

Returns the block $blockname in the parent_block

public boolean
# is_true( string $value )

Tells whether a condition is true. Conditions are global boolean variables.

public string
# get( string $varname )

Returns the $varname variable content searched in from the $list

public string
# get_from_list( string $varname, mixed[] & $list )

Similar from the get_var method but it works with loop variables instead of global variables.

public
# bind_vars( TemplateData $data )

Binds vars on another TemplateData object. The two instances will share the same data.