1
0

IURLGenerator.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Julius Härtl <jus@bitgrid.net>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. namespace OCP;
  30. /**
  31. * Class to generate URLs
  32. * @since 6.0.0
  33. */
  34. interface IURLGenerator {
  35. /**
  36. * Regex for matching http(s) urls
  37. *
  38. * This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing
  39. *
  40. * @since 25.0.0
  41. */
  42. public const URL_REGEX = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi';
  43. /**
  44. * Regex for matching http(s) urls (without modifiers for client compatibility)
  45. *
  46. * This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing
  47. *
  48. * @since 25.0.0
  49. */
  50. public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
  51. /**
  52. * Returns the URL for a route
  53. * @param string $routeName the name of the route
  54. * @param array $arguments an array with arguments which will be filled into the url
  55. * @return string the url
  56. * @since 6.0.0
  57. */
  58. public function linkToRoute(string $routeName, array $arguments = []): string;
  59. /**
  60. * Returns the absolute URL for a route
  61. * @param string $routeName the name of the route
  62. * @param array $arguments an array with arguments which will be filled into the url
  63. * @return string the absolute url
  64. * @since 8.0.0
  65. */
  66. public function linkToRouteAbsolute(string $routeName, array $arguments = []): string;
  67. /**
  68. * @param string $routeName
  69. * @param array $arguments
  70. * @return string
  71. * @since 15.0.0
  72. */
  73. public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string;
  74. /**
  75. * Returns an URL for an image or file
  76. * @param string $appName the name of the app
  77. * @param string $file the name of the file
  78. * @param array $args array with param=>value, will be appended to the returned url
  79. * The value of $args will be urlencoded
  80. * @return string the url
  81. * @since 6.0.0
  82. */
  83. public function linkTo(string $appName, string $file, array $args = []): string;
  84. /**
  85. * Returns the link to an image, like linkTo but only with prepending img/
  86. * @param string $appName the name of the app
  87. * @param string $file the name of the file
  88. * @return string the url
  89. * @since 6.0.0
  90. */
  91. public function imagePath(string $appName, string $file): string;
  92. /**
  93. * Makes an URL absolute
  94. * @param string $url the url in the ownCloud host
  95. * @return string the absolute version of the url
  96. * @since 6.0.0
  97. */
  98. public function getAbsoluteURL(string $url): string;
  99. /**
  100. * @param string $key
  101. * @return string url to the online documentation
  102. * @since 8.0.0
  103. */
  104. public function linkToDocs(string $key): string;
  105. /**
  106. * Returns the URL of the default page based on the system configuration
  107. * and the apps visible for the current user
  108. * @return string
  109. * @since 23.0.0
  110. */
  111. public function linkToDefaultPageUrl(): string;
  112. /**
  113. * @return string base url of the current request
  114. * @since 13.0.0
  115. */
  116. public function getBaseUrl(): string;
  117. /**
  118. * @return string webroot part of the base url
  119. * @since 23.0.0
  120. */
  121. public function getWebroot(): string;
  122. }