You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Template.php 3.8KB

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