|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* Smarty plugin
|
|
Chris PeBenito |
696b41 |
* @package Smarty
|
|
Chris PeBenito |
696b41 |
* @subpackage plugins
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/**
|
|
Chris PeBenito |
696b41 |
* load a resource plugin
|
|
Chris PeBenito |
696b41 |
*
|
|
Chris PeBenito |
696b41 |
* @param string $type
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
// $type
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
function smarty_core_load_resource_plugin($params, &$smarty)
|
|
Chris PeBenito |
696b41 |
{
|
|
Chris PeBenito |
696b41 |
/*
|
|
Chris PeBenito |
696b41 |
* Resource plugins are not quite like the other ones, so they are
|
|
Chris PeBenito |
696b41 |
* handled differently. The first element of plugin info is the array of
|
|
Chris PeBenito |
696b41 |
* functions provided by the plugin, the second one indicates whether
|
|
Chris PeBenito |
696b41 |
* all of them exist or not.
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_plugin = &$smarty->_plugins['resource'][$params['type']];
|
|
Chris PeBenito |
696b41 |
if (isset($_plugin)) {
|
|
Chris PeBenito |
696b41 |
if (!$_plugin[1] && count($_plugin[0])) {
|
|
Chris PeBenito |
696b41 |
$_plugin[1] = true;
|
|
Chris PeBenito |
696b41 |
foreach ($_plugin[0] as $_plugin_func) {
|
|
Chris PeBenito |
696b41 |
if (!is_callable($_plugin_func)) {
|
|
Chris PeBenito |
696b41 |
$_plugin[1] = false;
|
|
Chris PeBenito |
696b41 |
break;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
if (!$_plugin[1]) {
|
|
Chris PeBenito |
696b41 |
$smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
return;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
|
|
Chris PeBenito |
696b41 |
$_found = ($_plugin_file != false);
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
if ($_found) { /*
|
|
Chris PeBenito |
696b41 |
* If the plugin file is found, it -must- provide the properly named
|
|
Chris PeBenito |
696b41 |
* plugin functions.
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
include_once($_plugin_file);
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/*
|
|
Chris PeBenito |
696b41 |
* Locate functions that we require the plugin to provide.
|
|
Chris PeBenito |
696b41 |
*/
|
|
Chris PeBenito |
696b41 |
$_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
|
|
Chris PeBenito |
696b41 |
$_resource_funcs = array();
|
|
Chris PeBenito |
696b41 |
foreach ($_resource_ops as $_op) {
|
|
Chris PeBenito |
696b41 |
$_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
|
|
Chris PeBenito |
696b41 |
if (!function_exists($_plugin_func)) {
|
|
Chris PeBenito |
696b41 |
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
|
|
Chris PeBenito |
696b41 |
return;
|
|
Chris PeBenito |
696b41 |
} else {
|
|
Chris PeBenito |
696b41 |
$_resource_funcs[] = $_plugin_func;
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
$smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
}
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
/* vim: set expandtab: */
|
|
Chris PeBenito |
696b41 |
|
|
Chris PeBenito |
696b41 |
?>
|