navigationmanager.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. *
  8. */
  9. namespace OC;
  10. /**
  11. * Manages the ownCloud navigation
  12. */
  13. class NavigationManager implements \OCP\INavigationManager {
  14. protected $entries = array();
  15. protected $activeEntry;
  16. /**
  17. * Creates a new navigation entry
  18. * @param array $entry containing: id, name, order, icon and href key
  19. */
  20. public function add(array $entry) {
  21. $entry['active'] = false;
  22. if(!isset($entry['icon'])) {
  23. $entry['icon'] = '';
  24. }
  25. $this->entries[] = $entry;
  26. }
  27. /**
  28. * returns all the added Menu entries
  29. * @return array an array of the added entries
  30. */
  31. public function getAll() {
  32. return $this->entries;
  33. }
  34. /**
  35. * removes all the entries
  36. */
  37. public function clear() {
  38. $this->entries = array();
  39. }
  40. /**
  41. * Sets the current navigation entry of the currently running app
  42. * @param string $id of the app entry to activate (from added $entry)
  43. */
  44. public function setActiveEntry($id) {
  45. $this->activeEntry = $id;
  46. }
  47. /**
  48. * gets the active Menu entry
  49. * @return string id or empty string
  50. *
  51. * This function returns the id of the active navigation entry (set by
  52. * setActiveEntry
  53. */
  54. public function getActiveEntry() {
  55. return $this->activeEntry;
  56. }
  57. }