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 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Georg Ehrke <georg@owncloud.com>
  6. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  7. * @author Joas Schilling <nickvergessen@owncloud.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. * @author Vincent Petry <pvince81@owncloud.com>
  13. *
  14. * @copyright Copyright (c) 2015, ownCloud, Inc.
  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. /**
  31. * Public interface of ownCloud for apps to use.
  32. * Template Class
  33. *
  34. */
  35. // use OCP namespace for all classes that are considered public.
  36. // This means that they should be used by apps instead of the internal ownCloud classes
  37. namespace OCP;
  38. /**
  39. * Make OC_Helper::imagePath available as a simple function
  40. * @param string $app
  41. * @param string $image
  42. * @return string to the image
  43. *
  44. * @see OC_Helper::imagePath
  45. * @deprecated 8.0.0 Use \OCP\Template::image_path() instead
  46. */
  47. function image_path( $app, $image ) {
  48. return(\image_path( $app, $image ));
  49. }
  50. /**
  51. * Make OC_Helper::mimetypeIcon available as a simple function
  52. * @param string $mimetype
  53. * @return string to the image of this file type.
  54. * @deprecated 8.0.0 Use \OCP\Template::mimetype_icon() instead
  55. */
  56. function mimetype_icon( $mimetype ) {
  57. return(\mimetype_icon( $mimetype ));
  58. }
  59. /**
  60. * Make preview_icon available as a simple function
  61. * @param string $path path to file
  62. * @return string to the preview of the image
  63. * @deprecated 8.0.0 Use \OCP\Template::preview_icon() instead
  64. */
  65. function preview_icon( $path ) {
  66. return(\preview_icon( $path ));
  67. }
  68. /**
  69. * Make publicpreview_icon available as a simple function
  70. * Returns the path to the preview of the image.
  71. * @param string $path of file
  72. * @param string $token
  73. * @return string link to the preview
  74. * @deprecated 8.0.0 Use \OCP\Template::publicPreview_icon() instead
  75. */
  76. function publicPreview_icon ( $path, $token ) {
  77. return(\publicPreview_icon( $path, $token ));
  78. }
  79. /**
  80. * Make OC_Helper::humanFileSize available as a simple function
  81. * Example: 2048 to 2 kB.
  82. * @param int $bytes in bytes
  83. * @return string size as string
  84. * @deprecated 8.0.0 Use \OCP\Template::human_file_size() instead
  85. */
  86. function human_file_size( $bytes ) {
  87. return(\human_file_size( $bytes ));
  88. }
  89. /**
  90. * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
  91. * @param int $timestamp unix timestamp
  92. * @param boolean $dateOnly
  93. * @return \OC_L10N_String human readable interpretation of the timestamp
  94. *
  95. * @deprecated 8.0.0 Use \OCP\Template::relative_modified_date() instead
  96. */
  97. function relative_modified_date( $timestamp, $dateOnly = false ) {
  98. return(\relative_modified_date($timestamp, null, $dateOnly));
  99. }
  100. /**
  101. * Return a human readable outout for a file size.
  102. * @param integer $bytes size of a file in byte
  103. * @return string human readable interpretation of a file size
  104. * @deprecated 8.0.0 Use \OCP\Template::human_file_size() instead
  105. */
  106. function simple_file_size($bytes) {
  107. return(\human_file_size($bytes));
  108. }
  109. /**
  110. * Generate html code for an options block.
  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. * @deprecated 8.0.0 Use \OCP\Template::html_select_options() instead
  116. */
  117. function html_select_options($options, $selected, $params=array()) {
  118. return(\html_select_options($options, $selected, $params));
  119. }
  120. /**
  121. * This class provides the template system for owncloud. You can use it to load
  122. * specific templates, add data and generate the html code
  123. *
  124. * @since 8.0.0
  125. */
  126. class Template extends \OC_Template {
  127. /**
  128. * Make OC_Helper::imagePath available as a simple function
  129. *
  130. * @see OC_Helper::imagePath
  131. *
  132. * @param string $app
  133. * @param string $image
  134. * @return string to the image
  135. * @since 8.0.0
  136. */
  137. public static function image_path($app, $image) {
  138. return \image_path($app, $image);
  139. }
  140. /**
  141. * Make OC_Helper::mimetypeIcon available as a simple function
  142. *
  143. * @param string $mimetype
  144. * @return string to the image of this file type.
  145. * @since 8.0.0
  146. */
  147. public static function mimetype_icon($mimetype) {
  148. return \mimetype_icon($mimetype);
  149. }
  150. /**
  151. * Make preview_icon available as a simple function
  152. *
  153. * @param string $path path to file
  154. * @return string to the preview of the image
  155. * @since 8.0.0
  156. */
  157. public static function preview_icon($path) {
  158. return \preview_icon($path);
  159. }
  160. /**
  161. * Make publicpreview_icon available as a simple function
  162. * Returns the path to the preview of the image.
  163. *
  164. * @param string $path of file
  165. * @param string $token
  166. * @return string link to the preview
  167. * @since 8.0.0
  168. */
  169. public static function publicPreview_icon($path, $token) {
  170. return \publicPreview_icon($path, $token);
  171. }
  172. /**
  173. * Make OC_Helper::humanFileSize available as a simple function
  174. * Example: 2048 to 2 kB.
  175. *
  176. * @param int $bytes in bytes
  177. * @return string size as string
  178. * @since 8.0.0
  179. */
  180. public static function human_file_size($bytes) {
  181. return \human_file_size($bytes);
  182. }
  183. /**
  184. * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
  185. *
  186. * @param int $timestamp unix timestamp
  187. * @param boolean $dateOnly
  188. * @return string human readable interpretation of the timestamp
  189. * @since 8.0.0
  190. */
  191. public static function relative_modified_date($timestamp, $dateOnly = false) {
  192. return \relative_modified_date($timestamp, null, $dateOnly);
  193. }
  194. /**
  195. * Generate html code for an options block.
  196. *
  197. * @param array $options the options
  198. * @param mixed $selected which one is selected?
  199. * @param array $params the parameters
  200. * @return string html options
  201. * @since 8.0.0
  202. */
  203. public static function html_select_options($options, $selected, $params=array()) {
  204. return \html_select_options($options, $selected, $params);
  205. }
  206. }