1
0

Template.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP;
  8. /**
  9. * This class provides the template system for owncloud. You can use it to load
  10. * specific templates, add data and generate the html code
  11. *
  12. * @since 8.0.0
  13. */
  14. class Template extends \OC_Template {
  15. /**
  16. * Make OC_Helper::imagePath available as a simple function
  17. *
  18. * @see \OCP\IURLGenerator::imagePath
  19. *
  20. * @param string $app
  21. * @param string $image
  22. * @return string to the image
  23. * @since 8.0.0
  24. * @suppress PhanDeprecatedFunction
  25. */
  26. public static function image_path($app, $image) {
  27. return \image_path($app, $image);
  28. }
  29. /**
  30. * Make OC_Helper::mimetypeIcon available as a simple function
  31. *
  32. * @param string $mimetype
  33. * @return string to the image of this file type.
  34. * @since 8.0.0
  35. * @suppress PhanDeprecatedFunction
  36. */
  37. public static function mimetype_icon($mimetype) {
  38. return \mimetype_icon($mimetype);
  39. }
  40. /**
  41. * Make preview_icon available as a simple function
  42. *
  43. * @param string $path path to file
  44. * @return string to the preview of the image
  45. * @since 8.0.0
  46. * @suppress PhanDeprecatedFunction
  47. */
  48. public static function preview_icon($path) {
  49. return \preview_icon($path);
  50. }
  51. /**
  52. * Make publicpreview_icon available as a simple function
  53. * Returns the path to the preview of the image.
  54. *
  55. * @param string $path of file
  56. * @param string $token
  57. * @return string link to the preview
  58. * @since 8.0.0
  59. * @suppress PhanDeprecatedFunction
  60. */
  61. public static function publicPreview_icon($path, $token) {
  62. return \publicPreview_icon($path, $token);
  63. }
  64. /**
  65. * Make OC_Helper::humanFileSize available as a simple function
  66. * Example: 2048 to 2 kB.
  67. *
  68. * @param int $bytes in bytes
  69. * @return string size as string
  70. * @since 8.0.0
  71. * @suppress PhanDeprecatedFunction
  72. */
  73. public static function human_file_size($bytes) {
  74. return \human_file_size($bytes);
  75. }
  76. /**
  77. * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
  78. *
  79. * @param int $timestamp unix timestamp
  80. * @param boolean $dateOnly
  81. * @return string human readable interpretation of the timestamp
  82. * @since 8.0.0
  83. * @suppress PhanDeprecatedFunction
  84. * @suppress PhanTypeMismatchArgument
  85. */
  86. public static function relative_modified_date($timestamp, $dateOnly = false) {
  87. return \relative_modified_date($timestamp, null, $dateOnly);
  88. }
  89. /**
  90. * Generate html code for an options block.
  91. *
  92. * @param array $options the options
  93. * @param mixed $selected which one is selected?
  94. * @param array $params the parameters
  95. * @return string html options
  96. * @since 8.0.0
  97. * @suppress PhanDeprecatedFunction
  98. */
  99. public static function html_select_options($options, $selected, $params = []) {
  100. return \html_select_options($options, $selected, $params);
  101. }
  102. }