SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/dbtools/sql.php

  1. <?php
  2. use Sprout\Helpers\Csrf;
  3. use Sprout\Helpers\Enc;
  4. ?>
  5.  
  6.  
  7. <form action="" method="post">
  8. <?= Csrf::token(); ?>
  9. <div class="sql-wrapper white-box -clearfix">
  10.  
  11. <div class="columns -clearfix">
  12.  
  13. <div class="column column-8">
  14.  
  15. <div class="field-element field-element--textbox">
  16. <div class="field-label -vis-hidden">
  17. <label for="query-box">Refine</label>
  18. </div>
  19. <div class="field-input sql-input-field">
  20. <textarea id="query-box" placeholder="Enter query" name="sql" spellcheck="false" class="sql textbox" rows="20"><?= Enc::html(@$_POST['sql']); ?></textarea>
  21. </div>
  22. </div>
  23.  
  24. <div class="variable-replacement">
  25. <div class="variable-replacement-rows">
  26.  
  27. <?php
  28. $row_num = 0;
  29. $hidden_class = '';
  30. foreach ($vars as $var) {
  31. if ($row_num) $hidden_class = ' field-element--hidden-label';
  32. ?>
  33.  
  34. <div class="variable-replacement-row columns">
  35. <div class="column column-6">
  36. <div class="field-element field-element--text<?= $hidden_class; ?>">
  37. <div class="field-label">
  38. <label for="variable-<?= $row_num; ?>">Variable</label>
  39. <div class="field-helper">Named: don't include leading colon &nbsp; Numeric: leave blank</div>
  40. </div>
  41. <div class="field-input">
  42. <input type="text" name="vars[<?= $row_num; ?>][key]" class="textbox" placeholder="e.g. name" id="variable-<?= $row_num; ?>" value="<?= Enc::html(@$var['key']); ?>">
  43. </div>
  44. </div>
  45. </div>
  46.  
  47. <div class="column column-6">
  48. <div class="field-element field-element--text<?= $hidden_class; ?>">
  49. <div class="field-label">
  50. <label for="replacement-<?= $row_num; ?>">Value</label>
  51. <div class="field-helper">This will be auto-escaped by PDO</div>
  52. </div>
  53. <div class="field-input">
  54. <input type="text" name="vars[<?= $row_num; ?>][val]" class="textbox" placeholder="e.g. John" id="replacement-<?= $row_num; ?>" value="<?= Enc::html(@$var['val']); ?>">
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59.  
  60. <?php
  61. ++$row_num;
  62. }
  63. ?>
  64.  
  65. </div>
  66. <button type="button" class="button button-grey button-icon icon-before icon-add variable-replacement-button-add-row"><span class="-vis-hidden">Add</span></button>
  67. </div>
  68.  
  69. <div class="submit-bar">
  70. <div class="field-element field-element--checkbox">
  71. <div class="field-element__input-set">
  72. <div class="fieldset-input">
  73. <input type="checkbox" id="do-explain" name="explain" <?= (!empty($_POST['explain']) ? 'checked' : ''); ?> value="1">
  74. <label for="do-explain">Do EXPLAIN as well</label>
  75. </div>
  76. </div>
  77. </div>
  78.  
  79. <div class="field-element field-element--checkbox">
  80. <div class="field-element__input-set">
  81. <div class="fieldset-input">
  82. <input type="checkbox" id="enable-profiling" name="profile" <?= (!empty($_POST['profile']) ? 'checked' : ''); ?> value="1">
  83. <label for="enable-profiling">Enable Profiling</label>
  84. </div>
  85. </div>
  86. </div>
  87.  
  88. <button type="submit" class="save button button-regular button-green icon-after icon-storage">Execute queries</button>
  89. </div>
  90.  
  91. </div>
  92.  
  93. <div id="table-list-wrap" class="column column-4">
  94.  
  95. <div class="field-element field-element--text field-element--icon-after field-element--icon-after--search field-element--hidden-label">
  96. <div class="field-label">
  97. <label for="refine-queries">Refine</label>
  98. </div>
  99. <div class="field-input">
  100. <input type="text" name="refine" class="textbox" placeholder="Refine" id="refine-queries" autocomplete="off">
  101. </div>
  102. </div>
  103.  
  104. <div class="field-element field-element--select field-element--select--multiple field-element--hidden-label">
  105. <div class="field-label">
  106. <label for="quick-query">Refine</label>
  107. </div>
  108. <div class="field-input">
  109. <select class="table-list" size="2" id="quick-query">
  110. <?php
  111. foreach ($tables as $t) {
  112. echo '<option>', Enc::html($t), '</option>';
  113. }
  114. ?>
  115. </select>
  116. </div>
  117. </div>
  118.  
  119. </div>
  120.  
  121. </div>
  122.  
  123. <div id="table-details"><div class="text-align-right"><button type="button" class="button button-icon icon-before icon-close button-grey button-hide-table-preview"><span class="-vis-hidden">Hide</span></button></div></div>
  124.  
  125. </div>
  126. </form>
  127.  
  128. <?= $results; ?>
  129.