class RedirectorsPlugin extends LMSPlugin
{
public function registerHandlers()
{
$this->handlers = array(
'menu_initialized' => array(
'class' => 'PluginMenuHandler',
'method' => 'drawMenu'
),
'modules_dir_initialized' => array(
'class' => 'PluginDirHandler',
'method' => 'addModulesDir'
),
'smarty_initialized' => array(
'class' => 'PluginDirHandler',
'method' => 'addTemplatesDir'
),
'lms_initialized' => array(
'class' => 'PluginMethodsHandler',
'method' => 'addPluginMethods' <==== tutaj próbowałem coś rzeźbić, ale bez efektów.
),
);
}
}
class PluginMenuHandler
{
/**
* Example handler that does nothing
*
* @param mixed $hook_data
*/
public function drawMenu($hook_data)
{
error_log("Genereting menu for redirectors");
$hook_data["redirectors"] = array(
"name" => trans("Customer messages"),
"img" => "../plugins/RedirectorsPlugin/img/user_comment.png",
"link" => "?m=customermessages",
"tip" => trans("User customer messges"),
"accesskey" => "z",
"prio" => "9",
"submenu" => array(
array(
"name" => trans("Redirector list"),
"link" => "?m=redirectorlist",
"tip" => trans("Redirector list"),
"prio" => 10
),
array(
"name" => trans("New redirector"),
"link" => "?m=redirectoradd",
"tip" => trans("Add new redirector"),
"prio" => 20
)
));
return $hook_data;
}
}
class PluginDirHandler
{
/**
* Example handler that does nothing
*
* @param mixed $hook_data
*/
public function addModulesDir($hook_data)
{
error_log("Adding modules directory for RedirectorsPlugin");
array_push($hook_data,SYS_DIR . "/plugins/RedirectorsPlugin/modules/");
return $hook_data;
}
public function addTemplatesDir($hook_data)
{
error_log("Adding modules directory for RedirectorsPlugin");
$hook_data->AddTemplateDir(SYS_DIR . "/plugins/RedirectorsPlugin/templates/");
//return $hook_data;
}
}
Więc podsumowując - na mój chłopski rozum - najbardziej urządzałoby mnie pobranie instancji klasy pluginu z poziomu $LMS i juz dalsza praca na niej. Czy jest to w miarę sensowne rozwiązanie ?
Pozdrawiam.