function createPluginInstance($plugin_name) { $class_name = makeClass($plugin_name); $obj = new $class_name(); $obj->id = $plugin_name; $obj->smarty = new Smarty(); $obj->smarty->compile_id = "plugins|{$plugin_name}"; $obj->smarty->template_dir = HAMMOCK_ROOT . "/plugins/{$plugin_name}/templates"; $obj->smarty->compile_dir = HAMMOCK_ROOT . "/data/templates_c"; $obj->smarty->register_function('hidden_fields', 'smarty_hidden_fields'); $obj->smarty->register_function('channel_select', 'channel_select'); $obj->smarty->register_function('bot_config', 'smarty_bot_config'); $obj->smarty->register_function('label', 'smarty_label_config'); $obj->smarty->register_compiler_function('add_js', 'smarty_add_js'); $obj->smarty->register_compiler_function('add_css', 'smarty_add_css'); $obj->smarty->register_function('output_js', 'smarty_output_js'); $obj->smarty->register_function('output_css', 'smarty_output_css'); #requires a slight change in templates, $asset instead of {asset}{/asset} $obj->smarty->assign('asset', $obj->getAssets()); $obj->smarty->assign_by_ref('this', $obj); return $obj; }
<?php $dir = dirname(__FILE__); include "{$dir}/lib/init.php"; verify_auth(); load_plugins(); # # get list of services and sort them # $services = array(); foreach (array_keys($plugins_services) as $k) { $t = makeClass($k); $temp = new $t(); $temp->id = $k; $temp->name = $temp::NAME; $temp->desc = $temp::DESC; $temp->tt = $temp::TOOLTIP; $services[] = $temp; } usort($services, 'local_sort'); function local_sort($a, $b) { return strcasecmp($a->name, $b->name); } $smarty->assign('services', split_sets($services, 3)); # # load auth services # $auth = array(); foreach (array_keys($plugins_auth) as $k) { $temp = new $k();