app.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Georg Ehrke <georg@owncloud.com>
  6. * @author Joas Schilling <nickvergessen@owncloud.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @copyright Copyright (c) 2015, ownCloud, Inc.
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. /**
  29. * Public interface of ownCloud for apps to use.
  30. * App Class
  31. *
  32. */
  33. // use OCP namespace for all classes that are considered public.
  34. // This means that they should be used by apps instead of the internal ownCloud classes
  35. namespace OCP;
  36. /**
  37. * This class provides functions to manage apps in ownCloud
  38. * @since 4.0.0
  39. */
  40. class App {
  41. /**
  42. * Adds an entry to the navigation
  43. *
  44. * This function adds a new entry to the navigation visible to users. $data
  45. * is an associative array.
  46. * The following keys are required:
  47. * - id: unique id for this entry ('addressbook_index')
  48. * - href: link to the page
  49. * - name: Human readable name ('Addressbook')
  50. *
  51. * The following keys are optional:
  52. * - icon: path to the icon of the app
  53. * - order: integer, that influences the position of your application in
  54. * the navigation. Lower values come first.
  55. *
  56. * @param array $data containing the data
  57. * @return boolean
  58. *
  59. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->add() instead to
  60. * register a closure, this helps to speed up all requests against ownCloud
  61. * @since 4.0.0
  62. */
  63. public static function addNavigationEntry($data) {
  64. \OC::$server->getNavigationManager()->add($data);
  65. return true;
  66. }
  67. /**
  68. * Marks a navigation entry as active
  69. * @param string $id id of the entry
  70. * @return boolean
  71. *
  72. * This function sets a navigation entry as active and removes the 'active'
  73. * property from all other entries. The templates can use this for
  74. * highlighting the current position of the user.
  75. *
  76. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->setActiveEntry() instead
  77. * @since 4.0.0
  78. */
  79. public static function setActiveNavigationEntry( $id ) {
  80. return \OC_App::setActiveNavigationEntry( $id );
  81. }
  82. /**
  83. * Register a Configuration Screen that should appear in the personal settings section.
  84. * @param string $app appid
  85. * @param string $page page to be included
  86. * @return void
  87. * @since 4.0.0
  88. */
  89. public static function registerPersonal( $app, $page ) {
  90. \OC_App::registerPersonal( $app, $page );
  91. }
  92. /**
  93. * Register a Configuration Screen that should appear in the Admin section.
  94. * @param string $app string appid
  95. * @param string $page string page to be included
  96. * @return void
  97. * @since 4.0.0
  98. */
  99. public static function registerAdmin( $app, $page ) {
  100. \OC_App::registerAdmin( $app, $page );
  101. }
  102. /**
  103. * Read app metadata from the info.xml file
  104. * @param string $app id of the app or the path of the info.xml file
  105. * @param boolean $path (optional)
  106. * @return array
  107. * @since 4.0.0
  108. */
  109. public static function getAppInfo( $app, $path=false ) {
  110. return \OC_App::getAppInfo( $app, $path);
  111. }
  112. /**
  113. * checks whether or not an app is enabled
  114. * @param string $app
  115. * @return boolean
  116. *
  117. * This function checks whether or not an app is enabled.
  118. * @since 4.0.0
  119. */
  120. public static function isEnabled( $app ) {
  121. return \OC_App::isEnabled( $app );
  122. }
  123. /**
  124. * Check if the app is enabled, redirects to home if not
  125. * @param string $app
  126. * @return void
  127. * @since 4.0.0
  128. */
  129. public static function checkAppEnabled( $app ) {
  130. \OC_Util::checkAppEnabled( $app );
  131. }
  132. /**
  133. * Get the last version of the app, either from appinfo/version or from appinfo/info.xml
  134. * @param string $app
  135. * @return string
  136. * @since 4.0.0
  137. */
  138. public static function getAppVersion( $app ) {
  139. return \OC_App::getAppVersion( $app );
  140. }
  141. }