SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/categories_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\Constants;
  18. use Sprout\Helpers\Enc;
  19. use Sprout\Helpers\Fb;
  20. use Sprout\Helpers\Form;
  21. use Sprout\Helpers\Inflector;
  22.  
  23. ?>
  24. <div class="inline-buttons sidebar-action-buttons -clearfix">
  25. <?php if (!empty($main_add)): ?>
  26. <a class="icon-after icon-add button button-small" href="admin/add/<?php echo Enc::html($controller_name); ?>">Add <?php echo Enc::html(Inflector::singular($friendly_name)); ?></a>
  27. <?php endif; ?>
  28. <a class="icon-after icon-add button button-small" href="admin/add/<?php echo Enc::html($controller_name . '_category'); ?>" rel="facebox">Add category</a>
  29. </div>
  30.  
  31. <ul class="tree-list">
  32. <?php
  33. $class = (@$_GET['_category_id'] === null ? 'all active-node' : 'all');
  34. ?>
  35.  
  36. <li class="node depth1 <?php echo $class; ?>">
  37. <div>
  38. <a class="node-link" href="admin/contents/<?php echo $controller_name; ?>">All <?php echo Enc::html(strtolower($friendly_name)); ?></a>
  39. </div>
  40. </li>
  41.  
  42.  
  43. <?php foreach ($categories as $cat): ?>
  44. <?php
  45. $name = Enc::html($cat['name']);
  46. $class = (@$_GET['_category_id'] === $cat['id'] ? 'category active-node' : 'category');
  47. ?>
  48.  
  49. <li class="node depth1 <?php echo $class; ?>">
  50. <div>
  51. <a class="node-link" href="admin/contents/<?php echo $controller_name; ?>?_category_id=<?php echo $cat['id']; ?>" rel="<?php echo $cat['id']; ?>"><?php echo $name; ?> <span class="tree-list-count"><?php echo $cat['num_items']; ?></span></a>
  52.  
  53. <button class="tree-list-settings-button icon-before icon-settings" type="button">Settings</button>
  54. <div class="tree-list-settings-dropdown dropdown-box">
  55. <ul class="tree-list-settings-dropdown-list list-style-2">
  56. <li class="tree-list-settings-dropdown-list-item">
  57. <a href="admin/contents/<?php echo $controller_name; ?>?_category_id=<?php echo $cat['id']; ?>">View <?php echo Inflector::plural('item', $cat['num_items']); ?></a>
  58. </li>
  59. <?php if ($category_archive and $cat['id']): ?>
  60. <?php if ($cat['show_admin']): ?>
  61. <li class="tree-list-settings-dropdown-list-item js--ajax-archive">
  62. <a href="admin/call/<?php echo $controller_name; ?>_category/ajaxArchiveAction/<?php echo $cat['id']; ?>">Archive Category</a>
  63. </li>
  64. <?php else: ?>
  65. <li class="tree-list-settings-dropdown-list-item js--ajax-archive">
  66. <a href="admin/call/<?php echo $controller_name; ?>_category/ajaxUnarchiveAction/<?php echo $cat['id']; ?>">Unarchive Category</a>
  67. </li>
  68. <?php endif;?>
  69. <?php endif; ?>
  70. <li class="tree-list-settings-dropdown-list-item">
  71. <a href="admin/add/<?php echo $controller_name; ?>?category_id=<?php echo $cat['id']; ?>">Add item</a>
  72. </li>
  73. <?php if ($cat['id']): ?>
  74. <li class="tree-list-settings-dropdown-list-item">
  75. <a href="admin/edit/<?php echo $controller_name; ?>_category/<?php echo $cat['id']; ?>">Edit</a>
  76. </li>
  77. <?php if ($cat['num_items'] > 1): ?>
  78. <li class="tree-list-settings-dropdown-list-item">
  79. <a href="admin/extra/<?php echo $controller_name; ?>_category/reorder/<?php echo $cat['id']; ?>">Reorder</a>
  80. </li>
  81. <?php endif; ?>
  82. <li class="tree-list-settings-dropdown-list-item">
  83. <a href="admin/delete/<?php echo $controller_name; ?>_category/<?php echo $cat['id']; ?>">Delete category</a>
  84. </li>
  85. <?php endif; ?>
  86. </ul>
  87. </div>
  88. </div>
  89. </li>
  90. <?php endforeach; ?>
  91. </ul>
  92. <?php if (isset($category_archive_type)): ?>
  93. <form class="sidebar-form category-archive-selection" method="get">
  94. <?php Fb::$data['category_type'] = $category_archive_type; ?>
  95. <?php Form::nextFieldDetails('Showing Categories', false); ?>
  96. <?php echo Form::dropdown('category_type', ['-wrapper-class' => 'small white', 'placeholder' => 'Archive', 'title' => 'Select whether to show live categories, archived or everything.'], Constants::$category_admin_options); ?>
  97. </form>
  98. <script type="text/javascript">
  99. $(function () {
  100. $('.category-archive-selection select[name="category_type"]').change(function () {
  101. $(this).closest('form').submit();
  102. });
  103. });
  104. </script>
  105. <?php endif; ?>
  106.