Template.php 3.6 KB

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