SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/dbtools/multimake_template.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.  
  17. use Sprout\Helpers\Fb;
  18. use Sprout\Helpers\MultiEdit;
  19.  
  20.  
  21. die("Don't run me!");
  22.  
  23. // VIEW
  24. ?>
  25.  
  26. <?= Fb::heading('People'); ?>
  27. <div id="multiedit-people">
  28. <input type="hidden" name="m_id">
  29.  
  30. //INPUTS//
  31.  
  32. </div>
  33.  
  34. //REORDER//
  35. <?php MultiEdit::itemName('Person'); ?>
  36. <?php MultiEdit::display('people', $data['multiedit_people']); ?>
  37.  
  38. <?php
  39. // CONTROLLER
  40.  
  41. # _editPreRender
  42. if (!isset($view->data['multiedit_people'])) {
  43. $view->data['multiedit_people'] = MultiEdit::load('user_people', ['user_id' => $item_id], 'record_order');
  44. }
  45.  
  46.  
  47. # _addSave and _editSave
  48. if (!is_array(@$_POST['multiedit_people'])) {
  49. $_POST['multiedit_people'] = [];
  50. }
  51.  
  52. //INIT_ORDER//
  53. $new_set = [];
  54. foreach ($_POST['multiedit_people'] as $idx => $data) {
  55. if (MultiEdit::recordEmpty($data)) continue;
  56.  
  57. $update_fields = [];
  58. $update_fields['id'] = (int) $data['id'];
  59. //UPDATES//
  60.  
  61. $new_set[] = $update_fields;
  62. }
  63. $this->replaceSet('user_people', $new_set, ['user_id' => $item_id]);
  64.  
  65. # _deleteSave method
  66.  
  67. $this->deleteRecord('user_people', $id);
  68.  
  69.  
  70.