server_plugins.lib.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * functions for displaying server plugins
  5. *
  6. * @usedby server_plugins.php
  7. *
  8. * @package PhpMyAdmin
  9. */
  10. if (! defined('PHPMYADMIN')) {
  11. exit;
  12. }
  13. /**
  14. * Returns the html for plugin and module Info.
  15. *
  16. * @param Array $plugins Plugin list
  17. *
  18. * @param Array $modules Module list
  19. *
  20. * @return string
  21. */
  22. function PMA_getPluginAndModuleInfo($plugins, $modules)
  23. {
  24. $html = '<script type="text/javascript">';
  25. $html .= 'pma_theme_image = "' . $GLOBALS['pmaThemeImage'] . '"';
  26. $html .= '</script>';
  27. $html .= '<div id="pluginsTabs">';
  28. $html .= '<ul>';
  29. $html .= '<li><a href="#plugins_plugins">' . __('Plugins') . '</a></li>';
  30. $html .= '<li><a href="#plugins_modules">' . __('Modules') . '</a></li>';
  31. $html .= '</ul>';
  32. $html .= PMA_getPluginTab($plugins);
  33. $html .= PMA_getModuleTab($modules);
  34. $html .= '</div>';
  35. return $html;
  36. }
  37. /**
  38. * Returns the html for plugin Tab.
  39. *
  40. * @param Array $plugins list
  41. *
  42. * @return string
  43. */
  44. function PMA_getPluginTab($plugins)
  45. {
  46. $html = '<div id="plugins_plugins">';
  47. $html .= '<div id="sectionlinks">';
  48. foreach ($plugins as $plugin_type => $plugin_list) {
  49. $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type));
  50. $html .= '<a href="#' . $key . '">'
  51. . htmlspecialchars($plugin_type) . '</a>' . "\n";
  52. }
  53. $html .= '</div>';
  54. $html .= '<br />';
  55. foreach ($plugins as $plugin_type => $plugin_list) {
  56. $key = 'plugins-' . preg_replace('/[^a-z]/', '', strtolower($plugin_type));
  57. sort($plugin_list);
  58. $html .= '<table class="data_full_width" id="' . $key . '">';
  59. $html .= '<caption class="tblHeaders">';
  60. $html .= '<a class="top" href="#serverinfo">';
  61. $html .= __('Begin');
  62. $html .= PMA_Util::getImage('s_asc.png');
  63. $html .= '</a>';
  64. $html .= htmlspecialchars($plugin_type);
  65. $html .= '</caption>';
  66. $html .= '<thead>';
  67. $html .= '<tr>';
  68. $html .= '<th>' . __('Plugin') . '</th>';
  69. $html .= '<th>' . __('Module') . '</th>';
  70. $html .= '<th>' . __('Library') . '</th>';
  71. $html .= '<th>' . __('Version') . '</th>';
  72. $html .= '<th>' . __('Author') . '</th>';
  73. $html .= '<th>' . __('License') . '</th>';
  74. $html .= '</tr>';
  75. $html .= '</thead>';
  76. $html .= '<tbody>';
  77. $html .= PMA_getPluginList($plugin_list);
  78. $html .= '</tbody>';
  79. $html .= '</table>';
  80. }
  81. $html .= '</div>';
  82. return $html;
  83. }
  84. /**
  85. * Returns the html for plugin List.
  86. *
  87. * @param Array $plugin_list list
  88. *
  89. * @return string
  90. */
  91. function PMA_getPluginList($plugin_list)
  92. {
  93. $html = "";
  94. $odd_row = false;
  95. foreach ($plugin_list as $plugin) {
  96. $odd_row = !$odd_row;
  97. $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
  98. $html .= '<th>' . htmlspecialchars($plugin['plugin_name']) . '</th>';
  99. $html .= '<td>' . htmlspecialchars($plugin['module_name']) . '</td>';
  100. $html .= '<td>' . htmlspecialchars($plugin['module_library']) . '</td>';
  101. $html .= '<td>' . htmlspecialchars($plugin['module_version']) . '</td>';
  102. $html .= '<td>' . htmlspecialchars($plugin['module_author']) . '</td>';
  103. $html .= '<td>' . htmlspecialchars($plugin['module_license']) . '</td>';
  104. $html .= '</tr>';
  105. }
  106. return $html;
  107. }
  108. /**
  109. * Returns the html for Module Tab.
  110. *
  111. * @param Array $modules list
  112. *
  113. * @return string
  114. */
  115. function PMA_getModuleTab($modules)
  116. {
  117. $html = '<div id="plugins_modules">';
  118. $html .= '<table class="data_full_width">';
  119. $html .= '<thead>';
  120. $html .= '<tr>';
  121. $html .= '<th>' . __('Module') . '</th>';
  122. $html .= '<th>' . __('Description') . '</th>';
  123. $html .= '<th>' . __('Library') . '</th>';
  124. $html .= '<th>' . __('Version') . '</th>';
  125. $html .= '<th>' . __('Author') . '</th>';
  126. $html .= '<th>' . __('License') . '</th>';
  127. $html .= '</tr>';
  128. $html .= '</thead>';
  129. $html .= '<tbody>';
  130. $html .= PMA_getModuleList($modules);
  131. $html .= '</tbody>';
  132. $html .= '</table>';
  133. $html .= '</div>';
  134. return $html;
  135. }
  136. /**
  137. * Returns the html for module List.
  138. *
  139. * @param Array $modules list
  140. *
  141. * @return string
  142. */
  143. function PMA_getModuleList($modules)
  144. {
  145. $html = "";
  146. $odd_row = false;
  147. foreach ($modules as $module_name => $module) {
  148. $odd_row = !$odd_row;
  149. $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
  150. $html .= '<th rowspan="2">' . htmlspecialchars($module_name) . '</th>';
  151. $html .= '<td>' . htmlspecialchars($module['info']['module_description'])
  152. . '</td>';
  153. $html .= '<td>' . htmlspecialchars($module['info']['module_library'])
  154. . '</td>';
  155. $html .= '<td>' . htmlspecialchars($module['info']['module_version'])
  156. . '</td>';
  157. $html .= '<td>' . htmlspecialchars($module['info']['module_author'])
  158. . '</td>';
  159. $html .= '<td>' . htmlspecialchars($module['info']['module_license'])
  160. . '</td>';
  161. $html .= '</tr>';
  162. $html .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
  163. $html .= '<td colspan="5">';
  164. $html .= '<table>';
  165. $html .= '<tbody>';
  166. foreach ($module['plugins'] as $plugin_type => $plugin_list) {
  167. $html .= '<tr class="noclick">';
  168. $html .= '<td><b class="plugin-type">'
  169. . htmlspecialchars($plugin_type) . '</b></td>';
  170. $html .= '<td>';
  171. for ($i = 0, $nb = count($plugin_list); $i < $nb; $i++) {
  172. $html .= ($i != 0 ? '<br />' : '')
  173. . htmlspecialchars($plugin_list[$i]['plugin_name']);
  174. if (!$plugin_list[$i]['is_active']) {
  175. $html .= ' <small class="attention">' . __('disabled')
  176. . '</small>';
  177. }
  178. }
  179. $html .= '</td>';
  180. $html .= '</tr>';
  181. }
  182. $html .= '</tbody>';
  183. $html .= '</table>';
  184. $html .= '</td>';
  185. $html .= '</tr>';
  186. }
  187. return $html;
  188. }
  189. ?>