}
function getSubjectParams($subject) {
+ global $plugin_manager;
+
$vars = array();
switch($subject) {
'column' => $_REQUEST['column']
));
break;
- // case 'plugin':
- // $vars = array('params' => array(
- // 'server' => $_REQUEST['server'],
- // 'subject' => 'plugin',
- // 'plugin' => $_REQUEST['plugin'],
- // 'database' => $_REQUEST['database'],
- // 'schema' => $_REQUEST['schema'],
- // 'action' => $_REQUEST['action']
- // ));
- // break;
+ case 'plugin':
+ $vars = array(
+ 'url' => 'plugin.php',
+ 'params' => array(
+ 'server' => $_REQUEST['server'],
+ 'subject' => 'plugin',
+ 'plugin' => $_REQUEST['plugin'],
+ ));
+
+ if (!is_null($plugin_manager->getPlugin($_REQUEST['plugin'])))
+ $vars['params'] = array_merge($vars['params'], $plugin_manager->getPlugin($_REQUEST['plugin'])->get_subject_params());
+ break;
default:
return false;
}
abstract function get_actions();
+ /**
+ * In some page (display, sql, ...), a "return" link will show up if
+ * $_GET['return'] = 'plugin' is given. The "get_subject_params" method
+ * of the plugin designated by $_GET['plugin'] is then called to add needed
+ * parameters in the href URL.
+ * This method can returns parameters based on context from $_REQUEST. See
+ * plugin Report as example.
+ *
+ * @returns an associative of parameter_name => value
+ */
+ function get_subject_params() {
+ $vars = array();
+ return $vars;
+ }
+
/**
* Get the plugin name, that will be used as identification
* @return $name
return $this->name;
}
+ /**
+ * Returns the structure suitable for the method $misc->icon() to print
+ * the given icon.
+ * @param $img - The icon name
+ * @return the information suitable for the method $misc->icon()
+ */
function icon($img) {
return array($this->name, $img);
}
$this->actions[$plugin_name] = $actions;
}
+ function getPlugin($plugin) {
+ if (isset($this->plugins_list[$plugin]))
+ return $this->plugins_list[$plugin];
+
+ return null;
+ }
+
/**
* Execute the plugins hook functions when needed.
* @param $hook - The place where the function will be called