Template.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Frank Karlitschek <frank@karlitschek.de>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP;
  28. /**
  29. * This class provides the template system for owncloud. You can use it to load
  30. * specific templates, add data and generate the html code
  31. *
  32. * @since 8.0.0
  33. */
  34. class Template extends \OC_Template {
  35. /**
  36. * Make OC_Helper::imagePath available as a simple function
  37. *
  38. * @see \OCP\IURLGenerator::imagePath
  39. *
  40. * @param string $app
  41. * @param string $image
  42. * @return string to the image
  43. * @since 8.0.0
  44. * @suppress PhanDeprecatedFunction
  45. */
  46. public static function image_path($app, $image) {
  47. return \image_path($app, $image);
  48. }
  49. /**
  50. * Make OC_Helper::mimetypeIcon available as a simple function
  51. *
  52. * @param string $mimetype
  53. * @return string to the image of this file type.
  54. * @since 8.0.0
  55. * @suppress PhanDeprecatedFunction
  56. */
  57. public static function mimetype_icon($mimetype) {
  58. return \mimetype_icon($mimetype);
  59. }
  60. /**
  61. * Make preview_icon available as a simple function
  62. *
  63. * @param string $path path to file
  64. * @return string to the preview of the image
  65. * @since 8.0.0
  66. * @suppress PhanDeprecatedFunction
  67. */
  68. public static function preview_icon($path) {
  69. return \preview_icon($path);
  70. }
  71. /**
  72. * Make publicpreview_icon available as a simple function
  73. * Returns the path to the preview of the image.
  74. *
  75. * @param string $path of file
  76. * @param string $token
  77. * @return string link to the preview
  78. * @since 8.0.0
  79. * @suppress PhanDeprecatedFunction
  80. */
  81. public static function publicPreview_icon($path, $token) {
  82. return \publicPreview_icon($path, $token);
  83. }
  84. /**
  85. * Make OC_Helper::humanFileSize available as a simple function
  86. * Example: 2048 to 2 kB.
  87. *
  88. * @param int $bytes in bytes
  89. * @return string size as string
  90. * @since 8.0.0
  91. * @suppress PhanDeprecatedFunction
  92. */
  93. public static function human_file_size($bytes) {
  94. return \human_file_size($bytes);
  95. }
  96. /**
  97. * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
  98. *
  99. * @param int $timestamp unix timestamp
  100. * @param boolean $dateOnly
  101. * @return string human readable interpretation of the timestamp
  102. * @since 8.0.0
  103. * @suppress PhanDeprecatedFunction
  104. * @suppress PhanTypeMismatchArgument
  105. */
  106. public static function relative_modified_date($timestamp, $dateOnly = false) {
  107. return \relative_modified_date($timestamp, null, $dateOnly);
  108. }
  109. /**
  110. * Generate html code for an options block.
  111. *
  112. * @param array $options the options
  113. * @param mixed $selected which one is selected?
  114. * @param array $params the parameters
  115. * @return string html options
  116. * @since 8.0.0
  117. * @suppress PhanDeprecatedFunction
  118. */
  119. public static function html_select_options($options, $selected, $params = []) {
  120. return \html_select_options($options, $selected, $params);
  121. }
  122. }