SproutCMS

This is the code documentation for the SproutCMS project

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

  1. <?php
  2. use Sprout\Helpers\Csrf;
  3. use Sprout\Helpers\Form;
  4. ?>
  5.  
  6. <form action="SITE/dbtools/importXmlAction" method="post" enctype="multipart/form-data">
  7. <div class="mainbar-with-right-sidebar">
  8.  
  9. <div class="white-box">
  10. <?php echo Csrf::token(); ?>
  11.  
  12. <?php
  13. Form::nextFieldDetails('Sub-site', true, 'Select sub-site to import into');
  14. echo Form::dropdown('subsite_id', [], $subsites);
  15. ?>
  16.  
  17. <div class="js-page-dropdown">
  18. <input type="hidden" name="page_id" value="0">
  19. </div>
  20.  
  21. <?php
  22. Form::nextFieldDetails('XML file', true, 'Sprout 2\'s CMS export XML');
  23. echo Form::upload('filename');
  24. ?>
  25. </div>
  26. </div>
  27.  
  28. <div class="right-sidebar">
  29. <div class="right-sidebar-anchor"></div>
  30. <div class="right-sidebar-inner">
  31. <div class="save-changes-box">
  32. <h2 class="icon-before icon-file_upload">Import Sprout 2 pages</h2>
  33. <div class="save-changes-box-bottom -clearfix">
  34. <button type="submit" class="save-changes-save-button button button-regular button-green icon-after icon-send">Import</button>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39.  
  40. </form>
  41.  
  42. <script>
  43. $(document).ready(function()
  44. {
  45. $('select[name="subsite_id"]').on('change', function()
  46. {
  47. var id = parseInt($(this).val());
  48. if (isNaN(id)) id = 0;
  49. $.ajax({
  50. url: 'dbtools/ajaxPageIds/' + id,
  51. dataType: 'html',
  52. success: function(html) {
  53. $('.js-page-dropdown').html(html);
  54. },
  55. error: function() {
  56. $('.js-page-dropdown').html('<input type="hidden" value="0" name="page_id">');
  57. }
  58. });
  59. });
  60. });
  61. </script>
  62.