template.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * Template Class
  25. *
  26. */
  27. // use OCP namespace for all classes that are considered public.
  28. // This means that they should be used by apps instead of the internal ownCloud classes
  29. namespace OCP;
  30. /**
  31. * Make OC_Helper::imagePath available as a simple function
  32. * @param string app
  33. * @param string image
  34. * @return link to the image
  35. *
  36. * @see OC_Helper::imagePath
  37. */
  38. function image_path( $app, $image ) {
  39. return(\image_path( $app, $image ));
  40. }
  41. /**
  42. * Make OC_Helper::mimetypeIcon available as a simple function
  43. * @param string mimetype
  44. * @return path to the image of this file type.
  45. */
  46. function mimetype_icon( $mimetype ) {
  47. return(\mimetype_icon( $mimetype ));
  48. }
  49. /**
  50. * Make preview_icon available as a simple function
  51. * @param string path of file
  52. * @return path to the preview of the image
  53. */
  54. function preview_icon( $path ) {
  55. return(\preview_icon( $path ));
  56. }
  57. /**
  58. * Make publicpreview_icon available as a simple function
  59. * Returns the path to the preview of the image.
  60. * @param string path of file
  61. * @param string token
  62. * @return link to the preview
  63. */
  64. function publicPreview_icon ( $path, $token ) {
  65. return(\publicPreview_icon( $path, $token ));
  66. }
  67. /**
  68. * Make OC_Helper::humanFileSize available as a simple function
  69. * Example: 2048 to 2 kB.
  70. * @param int size in bytes
  71. * @return size as string
  72. */
  73. 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. * @param int unix timestamp
  79. * @param boolean date only
  80. * @return human readable interpretation of the timestamp
  81. */
  82. function relative_modified_date( $timestamp, $dateOnly = false ) {
  83. return(\relative_modified_date($timestamp, null, $dateOnly));
  84. }
  85. /**
  86. * Return a human readable outout for a file size.
  87. * @deprecated human_file_size() instead
  88. * @param integer size of a file in byte
  89. * @return human readable interpretation of a file size
  90. */
  91. function simple_file_size($bytes) {
  92. return(\human_file_size($bytes));
  93. }
  94. /**
  95. * Generate html code for an options block.
  96. * @param $options the options
  97. * @param $selected which one is selected?
  98. * @param array the parameters
  99. * @return html options
  100. */
  101. function html_select_options($options, $selected, $params=array()) {
  102. return(\html_select_options($options, $selected, $params));
  103. }
  104. /**
  105. * This class provides the template system for owncloud. You can use it to load
  106. * specific templates, add data and generate the html code
  107. */
  108. class Template extends \OC_Template {
  109. }