SproutCMS

This is the code documentation for the SproutCMS project

source of /modules/Welcome/views/db_conf_form.php

  1. <?php
  2. /*
  3.  * kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  4.  * :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  5.  *
  6.  * Copyright (C) 2016 Karmabunny Pty Ltd.
  7.  *
  8.  * This file is a part of SproutCMS.
  9.  *
  10.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  11.  * of the GNU General Public License as published by the Free Software Foundation, either
  12.  * version 2 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16.  
  17. use Sprout\Helpers\Form;
  18. ?>
  19.  
  20.  
  21. <style>
  22. .login-box {
  23. max-width: 900px;
  24. margin: 2em auto;
  25. padding-top: 0;
  26. }
  27. </style>
  28.  
  29. <script>
  30. $(document).ready(function() {
  31. $('.js--test-connection').on('click', testConnection);
  32.  
  33. function testConnection() {
  34. var opts = {};
  35.  
  36. opts.host = $('input[name="host"]').val();
  37. opts.user = $('input[name="user"]').val();
  38. opts.pass = $('input[name="pass"]').val();
  39. opts.database = $('input[name="database"]').val();
  40.  
  41. if (opts.host == '') { alert('You must specify a host'); return; }
  42. if (opts.user == '') { alert('You must specify a user'); return; }
  43. if (opts.pass == '') { alert('You must specify a pass'); return; }
  44. if (opts.database == '') { alert('Please specify a database'); return; }
  45.  
  46. $.post('welcome/db_conf_test', opts, function(data) {
  47. alert(data.result);
  48. }, 'json');
  49. }
  50. });
  51. </script>
  52.  
  53.  
  54. <form action="welcome/db_conf_result" method="post">
  55. <?php
  56. Form::nextFieldDetails('Environment', true);
  57. echo Form::multiradio('production', [], ['test' => 'Test server', 'live' => 'Live/production server']);
  58. ?>
  59.  
  60. <?php
  61. Form::nextFieldDetails('Hostname', true, 'This can be a hostname or an ip address (e.g. localhost or db-master.example.com)');
  62. echo Form::text('host');
  63. ?>
  64.  
  65. <?php
  66. Form::nextFieldDetails('Username', true, 'The database username (e.g. example_web)');
  67. echo Form::text('user');
  68. ?>
  69.  
  70. <?php
  71. Form::nextFieldDetails('Password', true, 'Note: This field is shown in plaintext');
  72. echo Form::text('pass');
  73. ?>
  74.  
  75. <?php
  76. Form::nextFieldDetails('Database name', true, 'The name of the actual database (e.g. example_v1)');
  77. echo Form::text('database');
  78. ?>
  79.  
  80. <div>
  81. <a href="welcome/checklist" class="button button-grey">Back</a>
  82. <button type="submit" class="right button button-green icon-before icon-save">Generate config</button>
  83. <button type="button" class="right button button-grey icon-before icon-build js--test-connection">Test connection</button>
  84. </div>
  85. </form>
  86.