app.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * App Class
  25. *
  26. */
  27. // use OCP namespace for all classes that are considered public.
  28. // This means that they should be used by apps instead of the internal ownCloud classes
  29. namespace OCP;
  30. /**
  31. * This class provides functions to manage apps in ownCloud
  32. */
  33. class App {
  34. /**
  35. * Makes ownCloud aware of this app
  36. * @param array $data with all information
  37. * @return boolean
  38. *
  39. * @deprecated This method is deprecated. Do not call it anymore.
  40. * It'll remain in our public API for compatibility reasons.
  41. *
  42. */
  43. public static function register( $data ) {
  44. return true; // don't do anything
  45. }
  46. /**
  47. * Adds an entry to the navigation
  48. *
  49. * This function adds a new entry to the navigation visible to users. $data
  50. * is an associative array.
  51. * The following keys are required:
  52. * - id: unique id for this entry ('addressbook_index')
  53. * - href: link to the page
  54. * - name: Human readable name ('Addressbook')
  55. *
  56. * The following keys are optional:
  57. * - icon: path to the icon of the app
  58. * - order: integer, that influences the position of your application in
  59. * the navigation. Lower values come first.
  60. *
  61. * @param array $data containing the data
  62. * @return boolean
  63. *
  64. * @deprecated Use \OC::$server->getNavigationManager()->add() instead to
  65. * register a closure, this helps to speed up all requests against ownCloud
  66. */
  67. public static function addNavigationEntry($data) {
  68. \OC::$server->getNavigationManager()->add($data);
  69. return true;
  70. }
  71. /**
  72. * Marks a navigation entry as active
  73. * @param string $id id of the entry
  74. * @return boolean
  75. *
  76. * This function sets a navigation entry as active and removes the 'active'
  77. * property from all other entries. The templates can use this for
  78. * highlighting the current position of the user.
  79. *
  80. * @deprecated Use \OC::$server->getNavigationManager()->setActiveEntry() instead
  81. */
  82. public static function setActiveNavigationEntry( $id ) {
  83. return \OC_App::setActiveNavigationEntry( $id );
  84. }
  85. /**
  86. * Register a Configuration Screen that should appear in the personal settings section.
  87. * @param string $app appid
  88. * @param string $page page to be included
  89. * @return void
  90. */
  91. public static function registerPersonal( $app, $page ) {
  92. \OC_App::registerPersonal( $app, $page );
  93. }
  94. /**
  95. * Register a Configuration Screen that should appear in the Admin section.
  96. * @param string $app string appid
  97. * @param string $page string page to be included
  98. * @return void
  99. */
  100. public static function registerAdmin( $app, $page ) {
  101. \OC_App::registerAdmin( $app, $page );
  102. }
  103. /**
  104. * Read app metadata from the info.xml file
  105. * @param string $app id of the app or the path of the info.xml file
  106. * @param boolean $path (optional)
  107. * @return array
  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. */
  119. public static function isEnabled( $app ) {
  120. return \OC_App::isEnabled( $app );
  121. }
  122. /**
  123. * Check if the app is enabled, redirects to home if not
  124. * @param string $app
  125. * @return void
  126. */
  127. public static function checkAppEnabled( $app ) {
  128. \OC_Util::checkAppEnabled( $app );
  129. }
  130. /**
  131. * Get the last version of the app, either from appinfo/version or from appinfo/info.xml
  132. * @param string $app
  133. * @return string
  134. */
  135. public static function getAppVersion( $app ) {
  136. return \OC_App::getAppVersion( $app );
  137. }
  138. }