changed git call from https to git readonly
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Smarty-2.6.0 / libs / core / core.load_resource_plugin.php
1 <?php\r
2 /**\r
3  * Smarty plugin\r
4  * @package Smarty\r
5  * @subpackage plugins\r
6  */\r
7 \r
8 /**\r
9  * load a resource plugin\r
10  *\r
11  * @param string $type\r
12  */\r
13 \r
14 // $type\r
15 \r
16 function smarty_core_load_resource_plugin($params, &$smarty)\r
17 {\r
18     /*\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
23      */\r
24 \r
25     $_plugin = &$smarty->_plugins['resource'][$params['type']];\r
26     if (isset($_plugin)) {\r
27         if (!$_plugin[1] && count($_plugin[0])) {\r
28             $_plugin[1] = true;\r
29             foreach ($_plugin[0] as $_plugin_func) {\r
30                 if (!is_callable($_plugin_func)) {\r
31                     $_plugin[1] = false;\r
32                     break;\r
33                 }\r
34             }\r
35         }\r
36 \r
37         if (!$_plugin[1]) {\r
38             $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);\r
39         }\r
40 \r
41         return;\r
42     }\r
43 \r
44     $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);\r
45     $_found = ($_plugin_file != false);\r
46 \r
47     if ($_found) {            /*\r
48          * If the plugin file is found, it -must- provide the properly named\r
49          * plugin functions.\r
50          */\r
51         include_once($_plugin_file);\r
52 \r
53         /*\r
54          * Locate functions that we require the plugin to provide.\r
55          */\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
62                 return;\r
63             } else {\r
64                 $_resource_funcs[] = $_plugin_func;\r
65             }\r
66         }\r
67 \r
68         $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);\r
69     }\r
70 }\r
71 \r
72 /* vim: set expandtab: */\r
73 \r
74 ?>\r