ServerPluginsController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Holds the PhpMyAdmin\Controllers\Server\ServerPluginsController
  5. *
  6. * @package PhpMyAdmin\Controllers
  7. */
  8. namespace PhpMyAdmin\Controllers\Server;
  9. use PhpMyAdmin\Controllers\Controller;
  10. use PhpMyAdmin\Server\Common;
  11. use PhpMyAdmin\Template;
  12. /**
  13. * Handles viewing server plugin details
  14. *
  15. * @package PhpMyAdmin\Controllers
  16. */
  17. class ServerPluginsController extends Controller
  18. {
  19. /**
  20. * @var array plugin details
  21. */
  22. protected $plugins;
  23. /**
  24. * Constructs ServerPluginsController
  25. */
  26. public function __construct($response, $dbi)
  27. {
  28. parent::__construct($response, $dbi);
  29. $this->_setServerPlugins();
  30. }
  31. /**
  32. * Index action
  33. *
  34. * @return void
  35. */
  36. public function indexAction()
  37. {
  38. include 'libraries/server_common.inc.php';
  39. $header = $this->response->getHeader();
  40. $scripts = $header->getScripts();
  41. $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
  42. $scripts->addFile('server_plugins.js');
  43. /**
  44. * Displays the page
  45. */
  46. $this->response->addHTML(
  47. Template::get('server/sub_page_header')->render([
  48. 'type' => 'plugins',
  49. ])
  50. );
  51. $this->response->addHTML($this->_getPluginsHtml());
  52. }
  53. /**
  54. * Sets details about server plugins
  55. *
  56. * @return void
  57. */
  58. private function _setServerPlugins()
  59. {
  60. $sql = "SELECT plugin_name,
  61. plugin_type,
  62. (plugin_status = 'ACTIVE') AS is_active,
  63. plugin_type_version,
  64. plugin_author,
  65. plugin_description,
  66. plugin_license
  67. FROM information_schema.plugins
  68. ORDER BY plugin_type, plugin_name";
  69. $res = $this->dbi->query($sql);
  70. $this->plugins = array();
  71. while ($row = $this->dbi->fetchAssoc($res)) {
  72. $this->plugins[$row['plugin_type']][] = $row;
  73. }
  74. $this->dbi->freeResult($res);
  75. ksort($this->plugins);
  76. }
  77. /**
  78. * Returns the html for plugin Tab.
  79. *
  80. * @return string
  81. */
  82. private function _getPluginsHtml()
  83. {
  84. $html = '<div id="plugins_plugins">';
  85. $html .= Template::get('server/plugins/section_links')
  86. ->render(array('plugins' => $this->plugins));
  87. foreach ($this->plugins as $plugin_type => $plugin_list) {
  88. $html .= Template::get('server/plugins/section')
  89. ->render(
  90. array(
  91. 'plugin_type' => $plugin_type,
  92. 'plugin_list' => $plugin_list,
  93. )
  94. );
  95. }
  96. $html .= '</div>';
  97. return $html;
  98. }
  99. }