diff --git a/htdocs/sql/libraries/plugin_interface.lib.php b/htdocs/sql/libraries/plugin_interface.lib.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/libraries/plugin_interface.lib.php @@ -0,0 +1,373 @@ + $val) { + $ret .= '' . "\n"; + $ret .= '' . "\n"; + $ret .= '' . "\n"; + $ret .= '

' . "\n"; + } + return $ret; +} + +/** + * string PMA_pluginGetOneOption(string $section, string $plugin_name, string $id, array &$opt) + * + * returns single option in a table row + * + * @uses PMA_getString() + * @uses PMA_pluginCheckboxCheck() + * @uses PMA_pluginGetDefault() + * @param string $section name of config section in + * $GLOBALS['cfg'][$section] for plugin + * @param string $plugin_name unique plugin name + * @param string $id option id + * @param array &$opt plugin option details + * @return string table row with option + */ +function PMA_pluginGetOneOption($section, $plugin_name, $id, &$opt) +{ + $ret = "\n"; + if ($opt['type'] == 'bool') { + $ret .= '
' . "\n"; + $ret .= '' + . PMA_getString($opt['text']) . ''; + $ret .= '
' . "\n"; + } elseif ($opt['type'] == 'text') { + $ret .= '
' . "\n"; + $ret .= ''; + $ret .= ''; + $ret .= '
' . "\n"; + } elseif ($opt['type'] == 'message_only') { + $ret .= '
' . "\n"; + $ret .= '

' . PMA_getString($opt['text']) . '

'; + $ret .= '
' . "\n"; + } elseif ($opt['type'] == 'select') { + $ret .= '
' . "\n"; + $ret .= ''; + $ret .= ''; + $ret .= '
' . "\n"; + } elseif ($opt['type'] == 'hidden') { + $ret .= ''; + } elseif ($opt['type'] == 'bgroup') { + $ret .= '
'; + /* No checkbox without name */ + if (!empty($opt['name'])) { + $ret .= '' + . PMA_getString($opt['text']) . ''; + } else { + $ret .= PMA_getString($opt['text']); + } + $ret .= ''; + } elseif ($opt['type'] == 'egroup') { + $ret .= '
'; + } else { + /* This should be seen only by plugin writers, so I do not thing this + * needs translation. */ + $ret .= 'UNKNOWN OPTION ' . $opt['type'] . ' IN IMPORT PLUGIN ' . $plugin_name . '!'; + } + if (isset($opt['doc'])) { + $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1]); + } + $ret .= "\n"; + return $ret; +} + +/** + * string PMA_pluginGetOptions(string $section, array &$list) + * + * return html fieldset with editable options for plugin + * + * @uses PMA_getString() + * @uses PMA_pluginGetOneOption() + * @param string $section name of config section in $GLOBALS['cfg'][$section] + * @param array &$list array with plugin configuration defined in plugin file + * @return string html fieldset with plugin options + */ +function PMA_pluginGetOptions($section, &$list) +{ + $ret = ''; + // Options for plugins that support them + foreach ($list as $plugin_name => $val) { + $ret .= '
'; + $ret .= '' . PMA_getString($val['options_text']) . ''; + $count = 0; + if (isset($val['options']) && count($val['options']) > 0) { + foreach ($val['options'] as $id => $opt) { + if ($opt['type'] != 'hidden') $count++; + $ret .= PMA_pluginGetOneOption($section, $plugin_name, $id, $opt); + } + } + if ($count == 0) { + $ret .= $GLOBALS['strNoOptions']; + } + $ret .= '
'; + } + return $ret; +} + +/** + * string PMA_pluginGetJavascript(array &$list) + * + * return html/javascript code which is needed for handling plugin stuff + * + * @param array &$list array with plugin configuration defined in plugin file + * @return string html fieldset with plugin options + */ +function PMA_pluginGetJavascript(&$list) { + $ret = ' + + '; + return $ret; +} +?>