view_operations.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. *
  5. * @package PhpMyAdmin
  6. */
  7. /**
  8. *
  9. */
  10. require_once './libraries/common.inc.php';
  11. $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
  12. /**
  13. * functions implementation for this script
  14. */
  15. require_once 'libraries/operations.lib.php';
  16. /**
  17. * Runs common work
  18. */
  19. require './libraries/tbl_common.inc.php';
  20. $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
  21. $url_params['goto'] = $url_params['back'] = 'view_operations.php';
  22. /**
  23. * Gets tables informations
  24. */
  25. require './libraries/tbl_info.inc.php';
  26. $reread_info = false;
  27. /**
  28. * Updates if required
  29. */
  30. if (isset($_REQUEST['submitoptions'])) {
  31. $_message = '';
  32. $warning_messages = array();
  33. if (isset($_REQUEST['new_name'])) {
  34. if ($pma_table->rename($_REQUEST['new_name'])) {
  35. $_message .= $pma_table->getLastMessage();
  36. $result = true;
  37. $GLOBALS['table'] = $pma_table->getName();
  38. $reread_info = true;
  39. $reload = true;
  40. } else {
  41. $_message .= $pma_table->getLastError();
  42. $result = false;
  43. }
  44. }
  45. }
  46. if (isset($result)) {
  47. // set to success by default, because result set could be empty
  48. // (for example, a table rename)
  49. $_type = 'success';
  50. if (empty($_message)) {
  51. $_message = $result
  52. ? __('Your SQL query has been executed successfully')
  53. : __('Error');
  54. // $result should exist, regardless of $_message
  55. $_type = $result ? 'success' : 'error';
  56. }
  57. if (! empty($warning_messages)) {
  58. $_message = new PMA_Message;
  59. $_message->addMessages($warning_messages);
  60. $_message->isError(true);
  61. unset($warning_messages);
  62. }
  63. echo PMA_Util::getMessage(
  64. $_message, $sql_query, $_type, $is_view = true
  65. );
  66. unset($_message, $_type);
  67. }
  68. $url_params['goto'] = 'view_operations.php';
  69. $url_params['back'] = 'view_operations.php';
  70. /**
  71. * Displays the page
  72. */
  73. ?>
  74. <!-- Table operations -->
  75. <div class="operations_half_width">
  76. <form method="post" action="view_operations.php">
  77. <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
  78. <input type="hidden" name="reload" value="1" />
  79. <fieldset>
  80. <legend><?php echo __('Operations'); ?></legend>
  81. <table>
  82. <!-- Change view name -->
  83. <tr><td><?php echo __('Rename view to'); ?></td>
  84. <td><input type="text" size="20" name="new_name" onfocus="this.select()"
  85. value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
  86. </td>
  87. </tr>
  88. </table>
  89. </fieldset>
  90. <fieldset class="tblFooters">
  91. <input type="hidden" name="submitoptions" value="1" />
  92. <input type="submit" value="<?php echo __('Go'); ?>" />
  93. </fieldset>
  94. </form>
  95. </div>
  96. <?php
  97. $drop_view_url_params = array_merge(
  98. $url_params,
  99. array(
  100. 'sql_query' => 'DROP VIEW ' . PMA_Util::backquote($GLOBALS['table']),
  101. 'goto' => 'tbl_structure.php',
  102. 'reload' => '1',
  103. 'purge' => '1',
  104. 'message_to_show' => sprintf(
  105. __('View %s has been dropped'),
  106. htmlspecialchars($GLOBALS['table'])
  107. ),
  108. 'table' => $GLOBALS['table']
  109. )
  110. );
  111. echo '<div class="operations_half_width">';
  112. echo '<fieldset class="caution">';
  113. echo '<legend>' . __('Delete data or table') . '</legend>';
  114. echo '<ul>';
  115. echo PMA_getDeleteDataOrTableLink(
  116. $drop_view_url_params,
  117. 'DROP VIEW',
  118. __('Delete the view (DROP)'),
  119. ''
  120. );
  121. echo '</ul>';
  122. echo '</fieldset>';
  123. echo '</div>';