game/onyx2/modules/templates/smarty/sysplugins/smarty_method_register_block.php

37 lines
967 B
PHP
Raw Normal View History

2020-11-15 15:12:32 +00:00
<?php
/**
* Smarty method Register_Block
*
* Registers a PHP function as Smarty block function plugin
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Register a PHP function as Smarty block function plugin
*/
/**
* Registers block function to be used in templates
*
* @param string $block_tag name of template block
* @param string $block_impl PHP function to register
* @param boolean $cacheable if true (default) this fuction is cachable
*/
function register_block($smarty, $block_tag, $block_impl, $cacheable = true, $cache_attr = array())
{
if (isset($smarty->registered_plugins[$block_tag])) {
throw new Exception("Plugin tag \"{$block_tag}\" already registered");
} elseif (!is_callable($block_impl)) {
throw new Exception("Plugin \"{$block_tag}\" not callable");
} else {
$smarty->registered_plugins[$block_tag] =
array('block', $block_impl, $cacheable, $cache_attr);
}
}
?>