rte_footer.lib.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Common functions for generating the footer for Routines, Triggers and Events.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Creates a fieldset for adding a new item, if the user has the privileges.
  13. *
  14. * @param string $docu String used to create a link to the MySQL docs
  15. * @param string $priv Privilege to check for adding a new item
  16. * @param string $name MySQL name of the item
  17. *
  18. * @return string An HTML snippet with the link to add a new item
  19. */
  20. function PMA_RTE_getFooterLinks($docu, $priv, $name)
  21. {
  22. global $db, $url_query, $ajax_class;
  23. $icon = 'b_' . strtolower($name) . '_add.png';
  24. $retval = "";
  25. $retval .= "<!-- ADD " . $name . " FORM START -->\n";
  26. $retval .= "<fieldset class='left'>\n";
  27. $retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
  28. $retval .= " <div class='wrap'>\n";
  29. $retval .= " <a {$ajax_class['add']} ";
  30. $retval .= "href='db_" . strtolower($name) . "s.php";
  31. $retval .= "?$url_query&amp;add_item=1' onclick='$.datepicker.initialized = false;'>";
  32. $retval .= PMA_Util::getIcon($icon);
  33. $retval .= PMA_RTE_getWord('add') . "</a>\n";
  34. $retval .= " " . PMA_Util::showMySQLDocu($docu) . "\n";
  35. $retval .= " </div>\n";
  36. $retval .= "</fieldset>\n";
  37. $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
  38. return $retval;
  39. } // end PMA_RTE_getFooterLinks()
  40. /**
  41. * Creates a fieldset for adding a new routine, if the user has the privileges.
  42. *
  43. * @return string HTML code with containing the fotter fieldset
  44. */
  45. function PMA_RTN_getFooterLinks()
  46. {
  47. return PMA_RTE_getFooterLinks('CREATE_PROCEDURE', 'CREATE ROUTINE', 'ROUTINE');
  48. }// end PMA_RTN_getFooterLinks()
  49. /**
  50. * Creates a fieldset for adding a new trigger, if the user has the privileges.
  51. *
  52. * @return string HTML code with containing the fotter fieldset
  53. */
  54. function PMA_TRI_getFooterLinks()
  55. {
  56. return PMA_RTE_getFooterLinks('CREATE_TRIGGER', 'TRIGGER', 'TRIGGER');
  57. } // end PMA_TRI_getFooterLinks()
  58. /**
  59. * Creates a fieldset for adding a new event, if the user has the privileges.
  60. *
  61. * @return string HTML code with containing the fotter fieldset
  62. */
  63. function PMA_EVN_getFooterLinks()
  64. {
  65. global $db, $url_query;
  66. /**
  67. * For events, we show the usual 'Add event' form and also
  68. * a form for toggling the state of the event scheduler
  69. */
  70. // Init options for the event scheduler toggle functionality
  71. $es_state = $GLOBALS['dbi']->fetchValue(
  72. "SHOW GLOBAL VARIABLES LIKE 'event_scheduler'",
  73. 0,
  74. 1
  75. );
  76. $es_state = strtolower($es_state);
  77. $options = array(
  78. 0 => array(
  79. 'label' => __('OFF'),
  80. 'value' => "SET GLOBAL event_scheduler=\"OFF\"",
  81. 'selected' => ($es_state != 'on')
  82. ),
  83. 1 => array(
  84. 'label' => __('ON'),
  85. 'value' => "SET GLOBAL event_scheduler=\"ON\"",
  86. 'selected' => ($es_state == 'on')
  87. )
  88. );
  89. // Generate output
  90. $retval = "<!-- FOOTER LINKS START -->\n";
  91. $retval .= "<div class='doubleFieldset'>\n";
  92. // show the usual footer
  93. $retval .= PMA_RTE_getFooterLinks('CREATE_EVENT', 'EVENT', 'EVENT');
  94. $retval .= " <fieldset class='right'>\n";
  95. $retval .= " <legend>\n";
  96. $retval .= " " . __('Event scheduler status') . "\n";
  97. $retval .= " </legend>\n";
  98. $retval .= " <div class='wrap'>\n";
  99. // show the toggle button
  100. $retval .= PMA_Util::toggleButton(
  101. "sql.php?$url_query&amp;goto=db_events.php" . urlencode("?db=$db"),
  102. 'sql_query',
  103. $options,
  104. 'PMA_slidingMessage(data.sql_query);'
  105. );
  106. $retval .= " </div>\n";
  107. $retval .= " </fieldset>\n";
  108. $retval .= " <div style='clear: both;'></div>\n";
  109. $retval .= "</div>";
  110. $retval .= "<!-- FOOTER LINKS END -->\n";
  111. return $retval;
  112. } // end PMA_EVN_getFooterLinks()
  113. ?>