SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/page_menu_groups.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 karmabunny\pdb\Exceptions\RowMissingException;
  17. use Sprout\Helpers\Csrf;
  18. use Sprout\Helpers\Enc;
  19. use Sprout\Helpers\FileConstants;
  20. use Sprout\Helpers\Form;
  21. use Sprout\Helpers\Pdb;
  22. ?>
  23.  
  24.  
  25. <style>span.mono { font-family: monospace; background: #eee; }</style>
  26. <div class="info">
  27. <p>Use this tool to change the headings for the navigation menu.</p>
  28. <p>Notes:</p>
  29. <ul>
  30. <li>The sections below represent the top-level pages on your website which have a multi-column menu</li>
  31. <li>Each heading in a section must have a unique name</li>
  32. <li>Use a leading dash to hide the heading; e.g. <span class="mono">-One</span></li>
  33. </ul>
  34. </div>
  35.  
  36.  
  37. <form action="admin/call/page/menuGroupsAction" method="post">
  38. <?= Csrf::token(); ?>
  39.  
  40. <?php
  41. foreach ($all_groups as $page_id => $groups) {
  42. try {
  43. $page = Pdb::get('pages', $page_id);
  44. } catch (RowMissingException $ex) {
  45. echo '<h3 style="color: red;">Page ' . (int)$page_id . ' does not exist</h3>';
  46. continue;
  47. }
  48. echo '<h3>', Enc::html($page['name']), '</h3>';
  49.  
  50.  
  51. if (array_sum($enabled_extras)) {
  52. Form::setData(array('extras' => $all_extras));
  53.  
  54. if (!empty($enabled_extras['text'])) {
  55. Form::nextFieldDetails('Description', false);
  56. echo Form::multiline("extras[{$page_id}][text]", ['rows' => 3, 'cols' => 30], []);
  57. }
  58.  
  59. if (!empty($enabled_extras['image'])) {
  60. Form::nextFieldDetails('Image', false);
  61. echo Form::fileselector("extras[{$page_id}][image]", [], ['type' => FileConstants::TYPE_IMAGE]);
  62. }
  63. }
  64.  
  65.  
  66. Form::setData(['groups' => $groups]);
  67.  
  68. $index = 1;
  69. foreach ($groups as $id => $name) {
  70. Form::nextFieldDetails('Group ' . $index, false);
  71. echo Form::text("groups[{$id}][name]");
  72. $index++;
  73. }
  74. }
  75. ?>
  76.  
  77. <div class="submit-bar">
  78. <button type="submit" class="button">Save changes</button>
  79. </div>
  80. </form>
  81.  
  82.  
  83.