SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/generic_import.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) 2015 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 3 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16. use Sprout\Helpers\Admin;
  17. use Sprout\Helpers\Csrf;
  18. use Sprout\Helpers\Enc;
  19. use Sprout\Helpers\Fb;
  20. use Sprout\Helpers\Form;
  21.  
  22.  
  23. Form::setData($data);
  24. ?>
  25.  
  26.  
  27. <form action="SITE/admin/import_action/<?php echo $controller_name; ?>" method="post">
  28. <?php echo Csrf::token(); ?>
  29. <input type="hidden" name="timestamp" value="<?php echo (int)$_GET['timestamp']; ?>">
  30.  
  31. <h3>Field mappings</h3>
  32. <table class="main-list">
  33. <thead>
  34. <tr><th>CSV field</th><th>Data sample</th><th>Database field</th></tr>
  35. </thead>
  36. <tbody>
  37. <?php foreach ($headings as $name): ?>
  38. <?php $post_name = Enc::httpfield($name); ?>
  39. <tr>
  40. <td><?php echo Enc::html($name); ?></td>
  41. <td><?php echo Enc::html(@implode(', ', $sample[$name])); ?></td>
  42. <td>
  43. <?php
  44. $params = ['style' => 'width: 225px;'];
  45. echo Fb::dropdown("columns[{$post_name}]", $params, $import_columns);
  46. ?>
  47. </td>
  48. </tr>
  49. <?php endforeach; ?>
  50. </tbody>
  51. </table>
  52.  
  53.  
  54. <?php if ($duplicate_options): ?>
  55. <h3>Duplicate records</h3>
  56. <?php
  57. Form::nextFieldDetails('Duplicates', true);
  58. echo Form::multiradio('duplicates', [], [
  59. 'new' => 'Add as new database record',
  60. 'merge' => 'Merge CSV record into existing database record',
  61. 'merge_blank' => 'Merge records, excluding blank fields',
  62. 'skip' => 'Skip CSV record',
  63. ]);
  64. ?>
  65.  
  66. <?php
  67. Form::nextFieldDetails('Match duplicates on', true);
  68. echo Form::dropdown('match_field', [], $import_columns);
  69. ?>
  70. <?php endif; ?>
  71.  
  72.  
  73. <?php echo $extra_options; ?>
  74.  
  75.  
  76. <div class="action-bar">
  77. <button type="submit" class="button">Import data</button>
  78. </div>
  79. </form>
  80. <?php Admin::clearFieldErrors(); ?>
  81.