SMARTY_VERSION
SMARTY_VERSION
The current version string for the current version of Brainy.
This is the main Brainy class
$default_template_handler_func : callable
Expects a function to use to fetch templates when it cannot be fetched through the default means. The function should use the following prototype:
It is expected to return a string (a path to a file) or false if no template could be loaded.
None found |
$default_config_handler_func : callable
Expects a function to use to fetch config when it cannot be fetched through the default means. The function should use the following prototype:
It is expected to return a string (a path to a file) or false if no config could be loaded.
None found |
$default_plugin_handler_func : callable
Expects a function to use to fetch plugins when it cannot be fetched through the default means. The function should use the following prototype:
It is expected to return a string (a path to a file) or false if no plugin could be loaded.
None found |
$force_compile : boolean
When true, Brainy will never use the compiled versions of templates, though compiled files will continue to be generated. This overrides `Smarty::$compile_check`. Do not use this in production.
None found |
$compile_check : boolean|integer
When true or Smarty::COMPILECHECK_ON, templates and config are checked for changes. If changes exist, the template will be recompiled regardless of whether it has been compiled or cached. Disabling this in production may yield performance improvements if templates and config do not change. If set to Smarty::COMPILECHECK_CACHEMISS, compiled templates are revalidated once a cache file is generated, preventing multiple compile_checks when a cached template expires.
None found |
$use_sub_dirs : boolean
When true, subdirectories will be created within the cache and compile directories. This is useful for applications with very large numbers of templates, as it minimizes the number of files in each of the directories. This does not work when PHP's safe_mode is set to on.
None found |
$allow_ambiguous_resources : boolean
When true, ambiguous resources are allowed.
None found |
$caching : boolean|integer
Controls the caching strategy.
None found |
$merge_compiled_includes : boolean
When true, included templates will be compiled into the templates that they are included in. The {include} function has an attribute that allows this to be performed on a case-by-case basis.
None found |
$inheritance_merge_compiled_includes : boolean
When true, templates will be compiled into the templates that they inherit from.
None found |
$cache_lifetime : integer
The amount of time that a cached template will live for.
Smarty::$caching must be turned on for this to have an effect.
-1 will prevent the cache from expiring. 0 will disable the cache.
None found |
$force_cache : boolean
When true, Brainy will never use the cached versions of templates, though cache files will continue to be generated if Smarty::$caching specifies it. Do not use this in production.
None found |
$cache_id : string
Set this if you want different sets of cache files for the same templates.
None found |
$compile_id : string
Set this if you want different sets of compiled files for the same templates.
None found |
$safe_lookups : integer
Indicates whether to perform only safe variable and member lookups.
If set to LOOKUP_SAFE, lookups referring to missing variables or members will return a falsey value. LOOKUP_SAFE_WARN will log a warning when the member does not exist.
None found |
None found |
$security_policy : \Smarty_Security
The Smarty_Security instance to use as a security policy.
None found |
$direct_access_security : boolean
When true, browsers will be blocked from accessing compiled or cached templates. Changing this to false is not recommended.
{@internal Currently used by Smarty_Internal_Template only. }}
todo |
Evaluate whether this is still useful |
---|
$error_reporting : integer|null
When set, this will be used as the default error reporting level.
None found |
$config_overwrite : boolean
When true, repeated values in config files will overwrite previous config values with the same name.
None found |
$config_booleanize : boolean
When true, config values of on/true/yes and off/false/no get converted to boolean values automatically rather than returning their string value.
None found |
$config_read_hidden : boolean
When true, hidden sections in config (sections whose names begin with a dot) will not be hidden.
None found |
$compile_locking : boolean
When true, concurrent template compilation is disabled.
None found |
$cache_locking : boolean
When true, cached templates will not be generated concurrently by multiple requests.
None found |
$locking_timeout : float
The maximum amount of time (in seconds) that a cached template will lock for, when $cache_locking is set.
None found |
$default_resource_type : string
resource type used if none given
Must be an valid key of $registered_resources.
None found |
$caching_type : string
The type of resource to use to load templates.
Must be an element of Smarty::$cache_resource_types.
None found |
$default_config_type : string
The type of resource to use to load config.
Must be an element of Smarty::$cache_resource_types.
None found |
$plugin_search_order : array<mixed,string>
The order in which to search for plugins
None found |
$escape_html : boolean
When true, all variables will be implicitly wrapped in
htmlspecialchars({$variable}, ENT_QUOTES, SMARTY_RESOURCE_CHAR_SET)
Variables may use the {$variable nofilter} syntax to prevent this behavior.
None found |
$template_dir : array|null
Directory that cached templates are stored in. See the following methods instead:
None found |
$compile_dir : string|null
Directory that compiled templates are stored in. See the following methods instead:
None found |
$plugins_dir : string|array|null
Directory that plugins are stored in. See the following methods instead:
None found |
$cache_dir : string|null
Directory that cached templates are stored in. See the following methods instead:
None found |
$config_dir : string|array|null
Directory that config files are stored in. See the following methods instead:
None found |
fetch(string $template = null, mixed $cache_id = null, mixed $compile_id = null, object $parent = null, boolean $display = false, boolean $merge_tpl_vars = true, boolean $no_output_filter = false) : string
Renders and returns a template.
This returns the template output instead of displaying it.
string | $template | the resource handle of the template file or template object |
mixed | $cache_id | cache id to be used with this template |
mixed | $compile_id | compile id to be used with this template |
object | $parent | next higher level of Smarty variables |
boolean | $display | true: display, false: fetch |
boolean | $merge_tpl_vars | if true parent template variables merged in to local scope |
boolean | $no_output_filter | if true do not run output filter |
rendered template output
None found |
display(string $template = null, mixed $cache_id = null, mixed $compile_id = null, object $parent = null) : void
Renders the template.
This displays the contents of a template. To return the contents of a template into a variable, use the fetch() method instead.
As an optional second and third parameter, you can pass a cache ID and compile ID.
A fourth parameter can be passed which passes the parent scope that the template should use.
string | $template | the resource handle of the template file or template object |
mixed | $cache_id | cache id to be used with this template |
mixed | $compile_id | compile id to be used with this template |
object | $parent | next higher level of Smarty variables |
None found |
isCached(string|object $template = null, mixed $cache_id = null, mixed $compile_id = null) : boolean
Returns whether the template is cached.
Note that calling this method will load the template into memory. Subsequent calls to fetch() or display() will not reload the template file. Calling clearCache() may also have no effect if this method has returned true.
string|object | $template | the resource handle of the template file or template object |
mixed | $cache_id | cache id to be used with this template |
mixed | $compile_id | compile id to be used with this template |
The template's cache status
None found |
createData(object|null $parent = null) : \Smarty_Data
Returns a new data object.
Data objects are used to create scopes for assigned variables. They can be used to have control which variables are seen by which templates.
object|null | $parent | Optional link to a parent scope |
data object
None found |
registerPlugin(string $type, string $tag, callable $callback, boolean $cacheable = true, array|null $cache_attr = null) : \Smarty_Internal_TemplateBase
Registers plugin to be used in templates
string | $type | plugin type |
string | $tag | name of template tag |
callable | $callback | PHP callback to register |
boolean | $cacheable | if true (default) this fuction is cachable |
array|null | $cache_attr | caching attributes if any |
when the plugin tag is invalid
Self-reference to facilitate chaining
None found |
unregisterPlugin(string $type, string $tag) : \Smarty_Internal_TemplateBase
Unregister Plugin
string | $type | of plugin |
string | $tag | name of plugin |
Self-reference to facilitate chaining
None found |
registerResource(string $type, \Smarty_Resource|array<mixed,\Smarty_Resource> $callback) : \Smarty_Internal_TemplateBase
Registers a resource to fetch a template
string | $type | name of resource type |
\Smarty_Resource|array<mixed,\Smarty_Resource> | $callback | Instance of Smarty_Resource, or array of callbacks to handle resource (deprecated) |
Self-reference to facilitate chaining
None found |
unregisterResource(string $type) : \Smarty_Internal_TemplateBase
Unregisters a resource
string | $type | name of resource type |
Self-reference to facilitate chaining
None found |
registerCacheResource(string $type, \Smarty_CacheResource $callback) : \Smarty_Internal_TemplateBase
Registers a cache resource to cache a template's output
string | $type | Name of cache resource type |
\Smarty_CacheResource | $callback | instance of Smarty_CacheResource to handle output caching |
Self-reference to facilitate chaining
None found |
unregisterCacheResource(string $type) : \Smarty_Internal_TemplateBase
Unregisters a cache resource
string | $type | name of cache resource type |
Self-reference to facilitate chaining
None found |
registerObject( $object_name, object $object_impl, array $allowed = array(), boolean $smarty_args = true, array $block_methods = array()) : \Smarty_Internal_TemplateBase
Registers object to be used in templates
$object_name | ||
object | $object_impl | the referenced PHP object to register |
array | $allowed | list of allowed methods (empty = all) |
boolean | $smarty_args | smarty argument format, else traditional |
array | $block_methods | list of block-methods |
if any of the methods in $allowed or $block_methods are invalid
Self-reference to facilitate chaining
None found |
getRegisteredObject(string $name) : mixed
Returns a reference to a registered object.
string | $name | object name |
if no such object is found
None found |
unregisterObject(string $name) : \Smarty_Internal_TemplateBase
unregister an object
string | $name | object name |
Self-reference to facilitate chaining
None found |
registerClass( $class_name, string $class_impl) : \Smarty_Internal_TemplateBase
Registers static classes to be used in templates
$class_name | ||
string | $class_impl | the referenced PHP class to register |
if $class_impl does not refer to an existing class
Self-reference to facilitate chaining
None found |
registerDefaultPluginHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default plugin handler
A default plugin handler gets called on undefined tags.
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerDefaultTemplateHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default template handler
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerDefaultConfigHandler(callable $callback) : \Smarty_Internal_TemplateBase
Registers a default template handler
callable | $callback | class/method name |
if $callback is not callable
Self-reference to facilitate chaining
None found |
registerFilter(string $type, callback $callback) : \Smarty_Internal_TemplateBase
Registers a filter function
string | $type | filter type |
callback | $callback |
Self-reference to facilitate chaining
None found |
unregisterFilter(string $type, callback $callback) : \Smarty_Internal_TemplateBase
Unregisters a filter function
string | $type | filter type |
callback | $callback |
Self-reference to facilitate chaining
None found |
loadFilter(string $type, string $name)
Load a filter of specified type and name
string | $type | filter type |
string | $name | filter name |
if filter could not be loaded
None found |
unloadFilter(string $type, string $name) : \Smarty_Internal_TemplateBase
unload a filter of specified type and name
string | $type | filter type |
string | $name | filter name |
Self-reference to facilitate chaining
None found |
assign(array|string $var, mixed $value = null) : \Smarty_Internal_Data
Assigns $var to the variable in $varname. If an associative array is passed as the only parameter, it is a mapping of variables to assign to the values to assign to them.
array|string | $var | the template variable name(s) |
mixed | $value | the value to assign |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
assignGlobal(string $varname, mixed $value = null) : \Smarty_Internal_Data
Assigns a global Smarty variable to the global scope.
string | $varname | the global variable name |
mixed | $value | the value to assign |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
todo |
This may not work with multiple Brainy instances. |
---|
assignByRef(string $tpl_var, $value) : \Smarty_Internal_Data
Assigns values to template variables by reference
string | $tpl_var | the template variable name |
$value |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
append(array|string $tpl_var, mixed $value = null, boolean $merge = false) : \Smarty_Internal_Data
Append an element to an assigned array
If you append to a string value, it is converted to an array value and then appended to. You can explicitly pass name/value pairs, or associative arrays containing the name/value pairs. If you pass the optional third parameter of true, the value will be merged with the current array instead of appended.
The $merge parameter does not use the PHP array_merge function. Merging two numerically indexed arrays may cause values to overwrite each other or result in non-sequential keys.
array|string | $tpl_var | the template variable name(s) |
mixed | $value | the value to append |
boolean | $merge | flag if array elements shall be merged |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
appendByRef(string $tpl_var, $value, boolean $merge = false) : \Smarty_Internal_Data
Appends values to template variables by reference
string | $tpl_var | the template variable name |
$value | ||
boolean | $merge | flag if array elements shall be merged |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
getTemplateVars(string $varname = null, \Smarty_Internal_Data $_ptr = null, boolean $search_parents = true) : string|array
Returns a single or all assigned template variables
string | $varname | Name of variable to process, or null to return all |
\Smarty_Internal_Data | $_ptr | Optional reference to data object |
boolean | $search_parents | Whether to include results from parent scopes |
variable value or or array of variables
None found |
clearAssign(string|array<mixed,string> $tpl_var) : \Smarty_Internal_Data
Clear the given assigned template variable.
string|array<mixed,string> | $tpl_var | The template variable(s) to clear |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
clearAllAssign() : \Smarty_Internal_Data
Clear all the assigned template variables.
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
configLoad(string $config_file, string|array<mixed,string>|null $sections = null) : \Smarty_Internal_Data
Load config file data and assign it to the template.
This works identically to the {config_load} function
string | $config_file | Path to the config file |
string|array<mixed,string>|null | $sections | Section name or array of section names |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
getVariable(string $variable, \Smarty_Internal_Data|null $_ptr = null, boolean $search_parents = true, boolean $error_enable = true) : mixed
Return the contents of an assigned variable.
string | $variable | the name of the Smarty variable |
\Smarty_Internal_Data|null | $_ptr | Optional reference to the data object |
boolean | $search_parents | Whether to search in the parent scope |
boolean | $error_enable | Whether to raise an error when the variable is not found. |
The contents of the variable.
None found |
getConfigVariable(string $variable, $error_enable = true) : mixed
gets a config variable
string | $variable | the name of the config variable |
$error_enable |
the value of the config variable
None found |
getStreamVariable(string $variable) : mixed
gets a stream variable
string | $variable | the stream of the variable |
the value of the stream variable
None found |
getConfigVars(string|null $varname = null, boolean $search_parents = true) : string
Returns a single or all config variables
string|null | $varname | Variable name or null (to retrieve all) |
boolean | $search_parents | Whether to search parent scopes |
variable value or or array of variables
None found |
clearConfig(string|null $varname = null) : \Smarty_Internal_Data
Clears all loaded config variables.
string|null | $varname | variable name or null |
current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
None found |
templateExists(string $resource_name) : boolean
Returns whether a template with the given name exists
string | $resource_name | template name |
Whether the template exists
None found |
getGlobal(string $varname = null) : mixed
Returns a single or all global variables
string | $varname | variable name or null |
Variable value or array of variable values
None found |
clearAllCache(integer|null $exp_time = null, string|null $type = null) : integer
Clear the entire template cache folder.
If $expire_time is set, only files older than $expire_time seconds will be deleted. Smarty::CLEAR_EXPIRED can also be passed to delete all expired templates.
integer|null | $exp_time | expiration time |
string|null | $type | resource type |
Number of cache files deleted
None found |
clearCache(string $template_name, string|null $cache_id = null, string|null $compile_id = null, integer|null $exp_time = null, string|null $type = null) : integer
Empty cache for a specific template.
If $cache_id or $compile_id are specified, they will limit the operation to only cached files with those IDs, respectively. If $expire_time is set, it will be used as the minimum age for files to be deleted. Smarty::CLEAR_EXPIRED can also be passed to delete all expired templates.
string | $template_name | template name |
string|null | $cache_id | cache id |
string|null | $compile_id | compile id |
integer|null | $exp_time | expiration time |
string|null | $type | resource type |
Number of cache files deleted
None found |
enableSecurity(string|\Smarty_Security $security_class = null) : \Smarty
Loads security class and enables security
string|\Smarty_Security | $security_class | if a string is used, it must be class-name |
when an invalid class name is provided
The current Smarty instance for chaining
None found |
disableSecurity() : \Smarty
Disable the currently loaded security policy.
The current Smarty instance for chaining
None found |
setTemplateDir(string|array<mixed,string> $template_dir) : \Smarty
Set template directory
string|array<mixed,string> | $template_dir | directory(s) of template sources |
The current Smarty instance for chaining
None found |
addTemplateDir(string|array $template_dir, string|null $key = null) : \Smarty
Add a directory to the list of directories where templates are stored
string|array | $template_dir | directory(s) of template sources |
string|null | $key | of the array element to assign the template dir to |
when the given template directory is not valid
The current Smarty instance for chaining
None found |
getTemplateDir(integer|null $index = null) : array|string
Get template directories
integer|null | $index | of directory to get, null to get all |
list of template directories, or directory of $index
None found |
setConfigDir(string|array<mixed,string> $config_dir) : \Smarty
Set config directory
string|array<mixed,string> | $config_dir | directory(s) of configuration sources |
The current Smarty instance for chaining
None found |
addConfigDir(string|array $config_dir, string|null $key = null) : \Smarty
Add a directory to the list of directories where config files are stored.
string|array | $config_dir | directory(s) of config sources |
string|null | $key | of the array element to assign the config dir to |
The current Smarty instance for chaining
None found |
getConfigDir(integer|null $index = null) : array|string
Get config directory
integer|null | $index | of directory to get, null to get all |
configuration directory
None found |
setPluginsDir(string|array $plugins_dir) : \Smarty
Set plugins directory
string|array | $plugins_dir | directory(s) of plugins |
current Smarty instance for chaining
None found |
addPluginsDir(string|array $plugins_dir) : \Smarty
Add a directory to the list of directories where plugins are stored
string|array | $plugins_dir | plugins folder |
current Smarty instance for chaining
None found |
getPluginsDir() : array<mixed,string>
Get plugin directories
List of plugin directories
None found |
setCompileDir(string $compile_dir) : \Smarty
Set compile directory
string | $compile_dir | directory to store compiled templates in |
current Smarty instance for chaining
None found |
getCompileDir() : string
Get compiled template directory
Path to compiled templates
None found |
setCacheDir(string $cache_dir) : \Smarty
Set cache directory
string | $cache_dir | directory to store cached templates in |
current Smarty instance for chaining
None found |
getCacheDir() : string
Get cached template directory
Path of cache directory
None found |
setDefaultModifiers(array|string $modifiers) : \Smarty
Set default modifiers
array|string | $modifiers | modifier or list of modifiers to set |
current Smarty instance for chaining
None found |
addDefaultModifiers(array|string $modifiers) : \Smarty
Add default modifiers
array|string | $modifiers | modifier or list of modifiers to add |
current Smarty instance for chaining
None found |
getDefaultModifiers() : array
Get default modifiers
list of default modifiers
None found |
setAutoloadFilters(array $filters, string|null $type = null) : \Smarty
Set autoload filters
array | $filters | filters to load automatically |
string|null | $type | "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types |
current Smarty instance for chaining
None found |
addAutoloadFilters(array $filters, string $type = null) : \Smarty
Add autoload filters
array | $filters | filters to load automatically |
string | $type | "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types |
current Smarty instance for chaining
None found |
getAutoloadFilters(string $type = null) : array
Get autoload filters
string | $type | type of filter to get autoloads for. Defaults to all autoload filters |
array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified
None found |
createTemplate(string $template, mixed $cache_id = null, mixed $compile_id = null, object|null $parent = null, boolean|null $do_clone = true) : object
Creates a template object.
This creates a template object which later can be rendered by the Smarty::display() or Smarty::fetch() method.
string | $template | the resource handle of the template file |
mixed | $cache_id | cache id to be used with this template |
mixed | $compile_id | compile id to be used with this template |
object|null | $parent | Parent scope to assign to the template |
boolean|null | $do_clone | When true, the Smarty object will be cloned |
template object
None found |
loadPlugin(string $plugin_name, boolean $check = false) : string
Takes unknown classes and loads plugin files for them class name format: Smarty_PluginType_PluginName plugin filename format: plugintype.pluginname.php
string | $plugin_name | class plugin name to load |
boolean | $check | check if already loaded |
|boolean filepath of loaded file or false
None found |
compileAllTemplates(string $extension = '.tpl', boolean $force_compile = false, integer $time_limit, integer $max_errors = null) : integer
Compile all template files
string | $extension | Optional file extension |
boolean | $force_compile | Optional boolean that compiles all files instead of modified files |
integer | $time_limit | Optional integer to specify a runtime limit in seconds for the compilation process |
integer | $max_errors | Optional integer to set an error limit. If more errors occur, the function will abort |
number of template files recompiled
None found |
compileAllConfig(string $extension = '.conf', boolean $force_compile = false, integer $time_limit, integer $max_errors = null) : integer
Compile all config files
string | $extension | Optional file extension |
boolean | $force_compile | Optional boolean that compiles all files instead of modified files |
integer | $time_limit | Optional integer to specify a runtime limit in seconds for the compilation process |
integer | $max_errors | Optional integer to set an error limit. If more errors occur, the function will abort |
number of config files recompiled
None found |
clearCompiledTemplate(string|null $resource_name = null, string|null $compile_id = null, integer|null $exp_time = null) : integer
Delete a compiled template file.
This clears the compiled version of the specified template resource, or all compiled template files if one is not specified. If you pass a $compile_id only the compiled template for this specific $compile_id is cleared. If you pass an $exp_time, then only compiled templates older than $exp_time seconds are cleared, by default all compiled templates are cleared regardless of their age. This function is for advanced use only, not normally needed.
string|null | $resource_name | template name |
string|null | $compile_id | compile id |
integer|null | $exp_time | expiration time |
number of template files deleted
None found |
getTags(object $template) : array
Return array of tag/attributes of all tags used by an template
object | $template | The template object |
of tag/attributes
None found |
testInstall(array $errors = null) : boolean
Run installation test
This function verifies that all required working folders of the current installation can be accessed appropriately.
array | $errors | Array to write errors into, rather than outputting them |
true if setup is fine, false if something is wrong
None found |
mutingErrorHandler(integer $errno, $errstr, $errfile, $errline, $errcontext) : boolean
Error Handler to mute expected messages
integer | $errno | Error level |
$errstr | ||
$errfile | ||
$errline | ||
$errcontext |
None found |
muteExpectedErrors() : void
Enable error handler to mute expected messages
error muting is done because some people implemented custom error_handlers using http://php.net/set_error_handler and for some reason did not understand the following paragraph:
It is important to remember that the standard PHP error handler is completely bypassed for the
error types specified by error_types unless the callback function returns FALSE.
error_reporting() settings will have no effect and your error handler will be called regardless -
however you are still able to read the current value of error_reporting and act appropriately.
Of particular note is that this value will be 0 if the statement that caused the error was
prepended by the @ error-control operator.
A call to @filemtime() is used instead of file_exists() and filemtime() in some places. Reasons include:
None found |
None found |
replaceCamelcase(string $match) : string
preg_replace callback to convert camelcase getter/setter to underscore property names
string | $match | match string |
replacemant
None found |