Completed
Push — master ( bf680a...c14dad )
by Morris
94:09 queued 79:58
created

Template.php ➔ simple_file_size()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Bart Visscher <[email protected]>
6
 * @author Frank Karlitschek <[email protected]>
7
 * @author Georg Ehrke <[email protected]>
8
 * @author Joas Schilling <[email protected]>
9
 * @author Jörn Friedrich Dreyer <[email protected]>
10
 * @author Lukas Reschke <[email protected]>
11
 * @author Morris Jobke <[email protected]>
12
 * @author Robin McCorkell <[email protected]>
13
 * @author Roeland Jago Douma <[email protected]>
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
31
namespace OCP;
32
33
/**
34
 * This class provides the template system for owncloud. You can use it to load
35
 * specific templates, add data and generate the html code
36
 *
37
 * @since 8.0.0
38
 */
39
class Template extends \OC_Template {
40
	/**
41
	 * Make OC_Helper::imagePath available as a simple function
42
	 *
43
	 * @see \OCP\IURLGenerator::imagePath
44
	 *
45
	 * @param string $app
46
	 * @param string $image
47
	 * @return string to the image
48
	 * @since 8.0.0
49
	 * @suppress PhanDeprecatedFunction
50
	 */
51
	public static function image_path($app, $image) {
52
		return \image_path($app, $image);
53
	}
54
55
56
	/**
57
	 * Make OC_Helper::mimetypeIcon available as a simple function
58
	 *
59
	 * @param string $mimetype
60
	 * @return string to the image of this file type.
61
	 * @since 8.0.0
62
	 * @suppress PhanDeprecatedFunction
63
	 */
64
	public static function mimetype_icon($mimetype) {
65
		return \mimetype_icon($mimetype);
66
	}
67
68
	/**
69
	 * Make preview_icon available as a simple function
70
	 *
71
	 * @param string $path path to file
72
	 * @return string to the preview of the image
73
	 * @since 8.0.0
74
	 * @suppress PhanDeprecatedFunction
75
	 */
76
	public static function preview_icon($path) {
77
		return \preview_icon($path);
78
	}
79
80
	/**
81
	 * Make publicpreview_icon available as a simple function
82
	 * Returns the path to the preview of the image.
83
	 *
84
	 * @param string $path of file
85
	 * @param string $token
86
	 * @return string link to the preview
87
	 * @since 8.0.0
88
	 * @suppress PhanDeprecatedFunction
89
	 */
90
	public static function publicPreview_icon($path, $token) {
91
		return \publicPreview_icon($path, $token);
92
	}
93
94
	/**
95
	 * Make OC_Helper::humanFileSize available as a simple function
96
	 * Example: 2048 to 2 kB.
97
	 *
98
	 * @param int $bytes in bytes
99
	 * @return string size as string
100
	 * @since 8.0.0
101
	 * @suppress PhanDeprecatedFunction
102
	 */
103
	public static function human_file_size($bytes) {
104
		return \human_file_size($bytes);
105
	}
106
107
	/**
108
	 * Return the relative date in relation to today. Returns something like "last hour" or "two month ago"
109
	 *
110
	 * @param int $timestamp unix timestamp
111
	 * @param boolean $dateOnly
112
	 * @return string human readable interpretation of the timestamp
113
	 * @since 8.0.0
114
	 * @suppress PhanDeprecatedFunction
115
	 * @suppress PhanTypeMismatchArgument
116
	 */
117
	public static function relative_modified_date($timestamp, $dateOnly = false) {
118
		return \relative_modified_date($timestamp, null, $dateOnly);
119
	}
120
121
	/**
122
	 * Generate html code for an options block.
123
	 *
124
	 * @param array $options the options
125
	 * @param mixed $selected which one is selected?
126
	 * @param array $params the parameters
127
	 * @return string html options
128
	 * @since 8.0.0
129
	 * @suppress PhanDeprecatedFunction
130
	 */
131
	public static function html_select_options($options, $selected, $params=array()) {
132
		return \html_select_options($options, $selected, $params);
133
	}
134
}
135