SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/operator_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\AdminPerms;
  18. use Sprout\Helpers\Enc;
  19. use Sprout\Helpers\Inflector;
  20.  
  21.  
  22.  
  23.  
  24. $actions = array();
  25. $actions['admin/add/' . $controller_name . '?category_id=%%'] = 'Add ' . Inflector::singular($friendly_name);
  26.  
  27. if (AdminPerms::canAccess('access_operators')) {
  28. $actions['admin/edit/' . $controller_name . '_category/%%'] = 'Edit category options';
  29. $actions['admin/delete/' . $controller_name . '_category/%%'] = 'Delete category';
  30. }
  31. ?>
  32.  
  33.  
  34. <script type="text/javascript">
  35. $(document).ready(function () {
  36. var actions = <?php echo json_encode($actions); ?>;
  37.  
  38. // Category actions box
  39. $('li.category a').mouseup(function(event) {
  40. if (event.button != 2) return false;
  41.  
  42. var cat_id = $(this).attr('rel');
  43.  
  44. var html = '<h3>Category actions</h3>';
  45. $.each(actions, function(url, label) {
  46. html += '<p><a href="' + url.replace('%%', cat_id) + '">' + label + '</a></p>';
  47. });
  48.  
  49. show_foldout(html, this);
  50.  
  51. event.stopPropagation();
  52. return false;
  53. });
  54.  
  55. $('li.category a').each(function(i) {
  56. this.oncontextmenu = function() {return false;};
  57. });
  58. });
  59. </script>
  60.  
  61.  
  62. <div class="inline-buttons sidebar-action-buttons -clearfix">
  63. <?php if (AdminPerms::canAccess('access_operators')): ?>
  64. <a class="icon-after icon-add button button-small" href="admin/add/<?php echo $controller_name; ?>">Add <?php echo Inflector::singular($friendly_name); ?></a>
  65. <?php endif; ?>
  66. <a class="icon-after icon-add button button-small" href="admin/add/<?php echo $controller_name . '_category'; ?>">Add category</a>
  67. </div>
  68.  
  69. <ul class="tree-list">
  70.  
  71. <li class="node depth1 all">
  72. <div>
  73. <a class="node-link" href="admin/contents/<?php echo $controller_name; ?>">All <?php echo strtolower($friendly_name); ?></a>
  74. </div>
  75. </li>
  76.  
  77. <?php
  78. foreach ($categories as $id => $name) {
  79. $name = Enc::html($name);
  80. $class = (@$_GET['_category_id'] == $id ? 'category current-edit' : 'category'); ?>
  81.  
  82. <li class="node depth1 <?php echo $class; ?>">
  83. <div>
  84.  
  85. <a class="node-link" href="admin/contents/<?php echo $controller_name; ?>?_category_id=<?php echo $id; ?>"><?php echo $name; ?></a>
  86.  
  87. <button class="tree-list-settings-button icon-before icon-settings" type="button">Settings</button>
  88. <div class="tree-list-settings-dropdown dropdown-box">
  89. <ul class="tree-list-settings-dropdown-list list-style-2">
  90. <li class="tree-list-settings-dropdown-list-item">
  91. <a href="#">Add <?php echo Inflector::singular($friendly_name); ?></a>
  92. </li>
  93. <li class="tree-list-settings-dropdown-list-item">
  94. <a href="#">Delete category</a>
  95. </li>
  96. </ul>
  97. </div>
  98.  
  99. </div>
  100. </li>
  101.  
  102. <?php } ?>
  103.  
  104. </ul>
  105.