2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * functions for displaying server plugins
7 * @usedby server_plugins.php
11 if (! defined('PHPMYADMIN')) {
16 * Get the HTML for the sub tabs
18 * @param string $activeUrl url of the active sub tab
20 * @return string HTML for sub tabs
22 function PMA_getHtmlForPluginsSubTabs($activeUrl)
24 $url_params = PMA_URL_getCommon();
27 'name' => __('Plugins'),
28 'url' => 'server_plugins.php'
31 'name' => __('Modules'),
32 'url' => 'server_modules.php'
36 $retval = '<ul id="topmenu2">';
37 foreach ($items as $item) {
39 if ($item['url'] === $activeUrl) {
40 $class = ' class="tabactive"';
43 $retval .= '<a' . $class;
44 $retval .= ' href="' . $item['url'] . $url_params . '">';
45 $retval .= $item['name'];
50 $retval .= '<div class="clearfloat"></div>';
56 * Returns the common SQL used to retrieve plugin and modules data
60 function PMA_getServerPluginModuleSQL()
62 return "SELECT p.plugin_name, p.plugin_type, p.is_active, m.module_name,
63 m.module_library, m.module_version, m.module_author,
64 m.module_description, m.module_license
65 FROM data_dictionary.plugins p
66 JOIN data_dictionary.modules m USING (module_name)
67 ORDER BY m.module_name, p.plugin_type, p.plugin_name";
71 * Returns details about server plugins
73 * @return array server plugins data
75 function PMA_getServerPlugins()
77 $sql = PMA_getServerPluginModuleSQL();
78 $res = $GLOBALS['dbi']->query($sql);
80 while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
81 $plugins[$row['plugin_type']][] = $row;
83 $GLOBALS['dbi']->freeResult($res);
89 * Returns details about server modules
91 * @return array server modules data
93 function PMA_getServerModules()
95 $sql = PMA_getServerPluginModuleSQL();
96 $res = $GLOBALS['dbi']->query($sql);
98 while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
99 $modules[$row['module_name']]['info'] = $row;
100 $modules[$row['module_name']]['plugins'][$row['plugin_type']][] = $row;
102 $GLOBALS['dbi']->freeResult($res);
107 * Returns the html for plugin Tab.
109 * @param Array $plugins list
113 function PMA_getPluginTab($plugins)
115 $html = '<div id="plugins_plugins">';
116 $html .= '<div id="sectionlinks">';
118 foreach ($plugins as $plugin_type => $plugin_list) {
120 . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
121 $html .= '<a href="#' . $key . '">'
122 . htmlspecialchars($plugin_type) . '</a>' . "\n";
128 foreach ($plugins as $plugin_type => $plugin_list) {
130 . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
133 $html .= '<table class="data_full_width" id="' . $key . '">';
134 $html .= '<caption class="tblHeaders">';
135 $html .= htmlspecialchars($plugin_type);
136 $html .= '</caption>';
139 $html .= '<th>' . __('Plugin') . '</th>';
140 $html .= '<th>' . __('Module') . '</th>';
141 $html .= '<th>' . __('Library') . '</th>';
142 $html .= '<th>' . __('Version') . '</th>';
143 $html .= '<th>' . __('Author') . '</th>';
144 $html .= '<th>' . __('License') . '</th>';
149 $html .= PMA_getPluginList($plugin_list);
159 * Returns the html for plugin List.
161 * @param Array $plugin_list list
165 function PMA_getPluginList($plugin_list)
169 foreach ($plugin_list as $plugin) {
170 $odd_row = !$odd_row;
171 $html .= '<tr class="noclick ' . ($odd_row ?
'odd' : 'even') . '">';
172 $html .= '<th>' . htmlspecialchars($plugin['plugin_name']) . '</th>';
173 $html .= '<td>' . htmlspecialchars($plugin['module_name']) . '</td>';
174 $html .= '<td>' . htmlspecialchars($plugin['module_library']) . '</td>';
175 $html .= '<td>' . htmlspecialchars($plugin['module_version']) . '</td>';
176 $html .= '<td>' . htmlspecialchars($plugin['module_author']) . '</td>';
177 $html .= '<td>' . htmlspecialchars($plugin['module_license']) . '</td>';
184 * Returns the html for Module Tab.
186 * @param Array $modules list
190 function PMA_getModuleTab($modules)
192 $html = '<div id="plugins_modules">';
193 $html .= '<table class="data_full_width">';
196 $html .= '<th>' . __('Module') . '</th>';
197 $html .= '<th>' . __('Description') . '</th>';
198 $html .= '<th>' . __('Library') . '</th>';
199 $html .= '<th>' . __('Version') . '</th>';
200 $html .= '<th>' . __('Author') . '</th>';
201 $html .= '<th>' . __('License') . '</th>';
206 $html .= PMA_getModuleList($modules);
214 * Returns the html for module List.
216 * @param Array $modules list
220 function PMA_getModuleList($modules)
224 foreach ($modules as $module_name => $module) {
225 $odd_row = !$odd_row;
226 $html .= '<tr class="noclick ' . ($odd_row ?
'odd' : 'even') . '">';
227 $html .= '<th rowspan="2">' . htmlspecialchars($module_name) . '</th>';
228 $html .= '<td>' . htmlspecialchars($module['info']['module_description'])
230 $html .= '<td>' . htmlspecialchars($module['info']['module_library'])
232 $html .= '<td>' . htmlspecialchars($module['info']['module_version'])
234 $html .= '<td>' . htmlspecialchars($module['info']['module_author'])
236 $html .= '<td>' . htmlspecialchars($module['info']['module_license'])
239 $html .= '<tr class="noclick ' . ($odd_row ?
'odd' : 'even') . '">';
240 $html .= '<td colspan="5">';
244 foreach ($module['plugins'] as $plugin_type => $plugin_list) {
245 $html .= '<tr class="noclick">';
246 $html .= '<td><b class="plugin-type">'
247 . htmlspecialchars($plugin_type) . '</b></td>';
249 for ($i = 0, $nb = count($plugin_list); $i < $nb; $i++
) {
250 $html .= ($i != 0 ?
'<br />' : '')
251 . htmlspecialchars($plugin_list[$i]['plugin_name']);
252 if (!$plugin_list[$i]['is_active']) {
253 $html .= ' <small class="attention">' . __('disabled')