1. Check existence of mb_string, mysql and xml extensions before installation.
[openemr.git] / phpmyadmin / libraries / server_plugins.lib.php
blob7e2274a321b45cab25de213d5d4cc8c6df61aa04
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * functions for displaying server plugins
7 * @usedby server_plugins.php
9 * @package PhpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
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();
25 $items = array(
26 array(
27 'name' => __('Plugins'),
28 'url' => 'server_plugins.php'
30 array(
31 'name' => __('Modules'),
32 'url' => 'server_modules.php'
36 $retval = '<ul id="topmenu2">';
37 foreach ($items as $item) {
38 $class = '';
39 if ($item['url'] === $activeUrl) {
40 $class = ' class="tabactive"';
42 $retval .= '<li>';
43 $retval .= '<a' . $class;
44 $retval .= ' href="' . $item['url'] . $url_params . '">';
45 $retval .= $item['name'];
46 $retval .= '</a>';
47 $retval .= '</li>';
49 $retval .= '</ul>';
50 $retval .= '<div class="clearfloat"></div>';
52 return $retval;
55 /**
56 * Returns the common SQL used to retrieve plugin and modules data
58 * @return string SQL
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";
70 /**
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);
79 $plugins = array();
80 while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
81 $plugins[$row['plugin_type']][] = $row;
83 $GLOBALS['dbi']->freeResult($res);
84 ksort($plugins);
85 return $plugins;
88 /**
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);
97 $modules = array();
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);
103 return $modules;
107 * Returns the html for plugin Tab.
109 * @param Array $plugins list
111 * @return string
113 function PMA_getPluginTab($plugins)
115 $html = '<div id="plugins_plugins">';
116 $html .= '<div id="sectionlinks">';
118 foreach ($plugins as $plugin_type => $plugin_list) {
119 $key = 'plugins-'
120 . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
121 $html .= '<a href="#' . $key . '">'
122 . htmlspecialchars($plugin_type) . '</a>' . "\n";
125 $html .= '</div>';
126 $html .= '<br />';
128 foreach ($plugins as $plugin_type => $plugin_list) {
129 $key = 'plugins-'
130 . preg_replace('/[^a-z]/', '', /*overload*/mb_strtolower($plugin_type));
131 sort($plugin_list);
133 $html .= '<table class="data_full_width" id="' . $key . '">';
134 $html .= '<caption class="tblHeaders">';
135 $html .= htmlspecialchars($plugin_type);
136 $html .= '</caption>';
137 $html .= '<thead>';
138 $html .= '<tr>';
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>';
145 $html .= '</tr>';
146 $html .= '</thead>';
147 $html .= '<tbody>';
149 $html .= PMA_getPluginList($plugin_list);
151 $html .= '</tbody>';
152 $html .= '</table>';
154 $html .= '</div>';
155 return $html;
159 * Returns the html for plugin List.
161 * @param Array $plugin_list list
163 * @return string
165 function PMA_getPluginList($plugin_list)
167 $html = "";
168 $odd_row = false;
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>';
178 $html .= '</tr>';
180 return $html;
184 * Returns the html for Module Tab.
186 * @param Array $modules list
188 * @return string
190 function PMA_getModuleTab($modules)
192 $html = '<div id="plugins_modules">';
193 $html .= '<table class="data_full_width">';
194 $html .= '<thead>';
195 $html .= '<tr>';
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>';
202 $html .= '</tr>';
203 $html .= '</thead>';
204 $html .= '<tbody>';
206 $html .= PMA_getModuleList($modules);
207 $html .= '</tbody>';
208 $html .= '</table>';
209 $html .= '</div>';
210 return $html;
214 * Returns the html for module List.
216 * @param Array $modules list
218 * @return string
220 function PMA_getModuleList($modules)
222 $html = "";
223 $odd_row = false;
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'])
229 . '</td>';
230 $html .= '<td>' . htmlspecialchars($module['info']['module_library'])
231 . '</td>';
232 $html .= '<td>' . htmlspecialchars($module['info']['module_version'])
233 . '</td>';
234 $html .= '<td>' . htmlspecialchars($module['info']['module_author'])
235 . '</td>';
236 $html .= '<td>' . htmlspecialchars($module['info']['module_license'])
237 . '</td>';
238 $html .= '</tr>';
239 $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
240 $html .= '<td colspan="5">';
241 $html .= '<table>';
242 $html .= '<tbody>';
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>';
248 $html .= '<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')
254 . '</small>';
257 $html .= '</td>';
258 $html .= '</tr>';
261 $html .= '</tbody>';
262 $html .= '</table>';
263 $html .= '</td>';
264 $html .= '</tr>';
266 return $html;