SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/page_navigation.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\Admin;
  18. use Sprout\Helpers\Inflector;
  19. use Sprout\Helpers\Needs;
  20. use Sprout\Helpers\Subsites;
  21. use Sprout\Helpers\AdminAuth;
  22.  
  23.  
  24. Needs::fileGroup('sprout/admin_page_navigation');
  25. ?>
  26.  
  27. <div class="inline-buttons sidebar-action-buttons -clearfix">
  28. <a class="icon-after icon-add tree-list-add button button-small" href="SITE/admin/add/<?php echo $controller_name; ?>">Add <?php echo Inflector::singular($friendly_name); ?></a>
  29. <?php if (AdminAuth::isSuper()): ?>
  30. <a class="icon-after icon-add tree-list-add button button-small" href="SITE/admin/add/<?php echo $controller_name; ?>?type=tool">Add tool <?php echo Inflector::singular($friendly_name); ?></a>
  31. <?php endif; ?>
  32. </div>
  33.  
  34. <ul class="tree-list">
  35. <?php
  36. $class = (Admin::getControllerSlug() === 'home_page' ? 'active-node' : '');
  37. ?>
  38.  
  39. <li class="node depth1 allow-access <?= $class; ?>" data-id="0">
  40. <div>
  41. <a class="node-link" href="SITE/admin/edit/home_page/<?= (int) $home_page_id; ?>">Home</a>
  42. <button class="tree-list-settings-button icon-before icon-settings" type="button">Settings</button>
  43. <div class="tree-list-settings-dropdown dropdown-box">
  44. <ul class="tree-list-settings-dropdown-list list-style-2">
  45. <li class="tree-list-settings-dropdown-list-item">
  46. <a href="SITE/admin/edit/home_page/<?= (int) $home_page_id; ?>">Edit home page</a>
  47. </li>
  48. </ul>
  49. </div>
  50. </div>
  51. </li>
  52.  
  53. <?php
  54. $nav_limit = Subsites::getConfigAdmin('nav_limit');
  55. if (! $nav_limit) $nav_limit = 99999;
  56. if (Subsites::getConfigAdmin('nav_home')) $nav_limit--;
  57.  
  58. $dropdown_actions = [
  59. [
  60. 'name' => 'Edit page',
  61. 'url' => 'admin/edit/page/%%',
  62. ],
  63. [
  64. 'name' => 'Add child',
  65. 'url' => 'admin/add/page?parent_id=%%',
  66. ],
  67. [
  68. 'name' => 'Reorder children',
  69. 'url' => 'admin/call/page/reorder/%%',
  70. 'class' => 'popup',
  71. ],
  72. [
  73. 'name' => 'Delete page',
  74. 'url' => 'admin/delete/page/%%',
  75. ],
  76. ];
  77.  
  78. $dropdown_actions_no_children = [
  79. [
  80. 'name' => 'Edit page',
  81. 'url' => 'admin/edit/page/%%',
  82. ],
  83. [
  84. 'name' => 'Add child',
  85. 'url' => 'admin/add/page?parent_id=%%',
  86. ],
  87. [
  88. 'name' => 'Delete page',
  89. 'url' => 'admin/delete/page/%%',
  90. ],
  91. ];
  92.  
  93. foreach ($root->children as $node) {
  94. if ($nav_limit == 0) {
  95. echo '</ul>';
  96. echo '<p class="page-tree-list-over-nav-limit">Pages not in navigation</p>';
  97. echo '<ul class="tree-list">';
  98. }
  99. if (count($node->children) > 0) {
  100. Admin::navigationTreeNode($node, $dropdown_actions);
  101. } else {
  102. Admin::navigationTreeNode($node, $dropdown_actions_no_children);
  103. }
  104.  
  105. $nav_limit--;
  106. }
  107. ?>
  108. </ul>
  109.  
  110.  
  111.  
  112.