5 * @subpackage plugins
\r
9 * load a resource plugin
\r
11 * @param string $type
\r
16 function smarty_core_load_resource_plugin($params, &$smarty)
\r
19 * Resource plugins are not quite like the other ones, so they are
\r
20 * handled differently. The first element of plugin info is the array of
\r
21 * functions provided by the plugin, the second one indicates whether
\r
22 * all of them exist or not.
\r
25 $_plugin = &$smarty->_plugins['resource'][$params['type']];
\r
26 if (isset($_plugin)) {
\r
27 if (!$_plugin[1] && count($_plugin[0])) {
\r
29 foreach ($_plugin[0] as $_plugin_func) {
\r
30 if (!is_callable($_plugin_func)) {
\r
31 $_plugin[1] = false;
\r
38 $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
\r
44 $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
\r
45 $_found = ($_plugin_file != false);
\r
48 * If the plugin file is found, it -must- provide the properly named
\r
51 include_once($_plugin_file);
\r
54 * Locate functions that we require the plugin to provide.
\r
56 $_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
\r
57 $_resource_funcs = array();
\r
58 foreach ($_resource_ops as $_op) {
\r
59 $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
\r
60 if (!function_exists($_plugin_func)) {
\r
61 $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
\r
64 $_resource_funcs[] = $_plugin_func;
\r
68 $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
\r
72 /* vim: set expandtab: */
\r