Revision 1023
Added by Matthias over 15 years ago
browse.php | ||
---|---|---|
31 | 31 |
// Include the WB functions file |
32 | 32 |
require_once(WB_PATH.'/framework/functions.php'); |
33 | 33 |
|
34 |
// Byte convert for filesize |
|
35 |
function byte_convert($bytes) { |
|
36 |
$symbol = array('B', 'KB', 'MB', 'GB', 'TB'); |
|
37 |
$exp = 0; |
|
38 |
$converted_value = 0; |
|
39 |
if( $bytes > 0 ) { |
|
40 |
$exp = floor( log($bytes)/log(1024) ); |
|
41 |
$converted_value = ( $bytes/pow(1024,floor($exp)) ); |
|
42 |
} |
|
43 |
return sprintf( '%.2f '.$symbol[$exp], $converted_value ); |
|
44 |
} |
|
45 |
|
|
46 |
// Get file extension |
|
47 |
function get_filetype($fname) { |
|
48 |
$pathinfo = pathinfo($fname); |
|
49 |
$extension = strtolower($pathinfo['extension']); |
|
50 |
return $extension; |
|
51 |
} |
|
52 |
|
|
53 |
// Get file extension for icons |
|
54 |
function get_filetype_icon($fname) { |
|
55 |
$pathinfo = pathinfo($fname); |
|
56 |
$extension = strtolower($pathinfo['extension']); |
|
57 |
if (file_exists(THEME_PATH.'/images/files/'.$extension.'.png')) { |
|
58 |
return $extension; |
|
59 |
} else { |
|
60 |
return 'unknown'; |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
34 | 64 |
// Setup template object |
35 | 65 |
$template = new Template(THEME_PATH.'/templates'); |
36 | 66 |
$template->set_file('page', 'media_browse.htt'); |
... | ... | |
74 | 104 |
'THEME_URL' => THEME_URL, |
75 | 105 |
'CURRENT_DIR' => $directory, |
76 | 106 |
'PARENT_DIR_LINK' => $parent_dir_link, |
77 |
'DISPLAY_UP_ARROW' => $display_up_arrow |
|
107 |
'DISPLAY_UP_ARROW' => $display_up_arrow, |
|
108 |
'INCLUDE_PATH' => WB_URL.'/include' |
|
78 | 109 |
) |
79 | 110 |
); |
80 | 111 |
|
... | ... | |
111 | 142 |
'LINK' => "browse.php?dir=$directory/$link_name", |
112 | 143 |
'LINK_TARGET' => '', |
113 | 144 |
'ROW_BG_COLOR' => $row_bg_color, |
114 |
'FILETYPE_ICON' => THEME_URL.'/images/folder_16.png' |
|
145 |
'FILETYPE_ICON' => THEME_URL.'/images/folder_16.png', |
|
146 |
'SIZE' => '', |
|
147 |
'DATE' => '', |
|
148 |
'PREVIEW' => '' |
|
115 | 149 |
) |
116 | 150 |
); |
117 | 151 |
$template->parse('list', 'list_block', true); |
... | ... | |
125 | 159 |
} |
126 | 160 |
if(isset($FILE)) { |
127 | 161 |
sort($FILE); |
162 |
$filepreview = array('jpg','gif','tif','tiff','png','txt','css','js','cfg','conf'); |
|
128 | 163 |
foreach($FILE AS $name) { |
164 |
$size = filesize('../../'.MEDIA_DIRECTORY.$directory.'/'.$name); |
|
165 |
$bytes = byte_convert($size); |
|
166 |
$fdate = filemtime('../../'.MEDIA_DIRECTORY.$directory.'/'.$name); |
|
167 |
$date = gmdate(DATE_FORMAT.' '.TIME_FORMAT, $fdate); |
|
168 |
$filetypeicon = get_filetype_icon(WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name); |
|
169 |
$filetype = get_filetype(WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name); |
|
170 |
|
|
171 |
if (in_array($filetype, $filepreview)) { |
|
172 |
$preview = 'preview'; |
|
173 |
} else { |
|
174 |
$preview = ''; |
|
175 |
} |
|
129 | 176 |
$temp_id++; |
130 | 177 |
$template->set_var(array( |
131 | 178 |
'NAME' => $name, |
... | ... | |
134 | 181 |
'LINK' => WB_URL.MEDIA_DIRECTORY.$directory.'/'.$name, |
135 | 182 |
'LINK_TARGET' => '_blank', |
136 | 183 |
'ROW_BG_COLOR' => $row_bg_color, |
137 |
'FILETYPE_ICON' => THEME_URL.'/images/blank.gif' |
|
184 |
'FILETYPE_ICON' => THEME_URL.'/images/files/'.$filetypeicon.'.png', |
|
185 |
'SIZE' => $bytes, |
|
186 |
'DATE' => $date, |
|
187 |
'PREVIEW' => $preview |
|
138 | 188 |
) |
139 | 189 |
); |
140 | 190 |
$template->parse('list', 'list_block', true); |
... | ... | |
170 | 220 |
'TEXT_RELOAD' => $TEXT['RELOAD'], |
171 | 221 |
'TEXT_RENAME' => $TEXT['RENAME'], |
172 | 222 |
'TEXT_DELETE' => $TEXT['DELETE'], |
223 |
'TEXT_SIZE' => $TEXT['SIZE'], |
|
224 |
'TEXT_DATE' => $TEXT['DATE'], |
|
225 |
'TEXT_NAME' => $TEXT['NAME'], |
|
226 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
173 | 227 |
'TEXT_UP' => $TEXT['UP'], |
174 | 228 |
'NONE_FOUND' => $MESSAGE['MEDIA']['NONE_FOUND'], |
175 | 229 |
'CONFIRM_DELETE' => $MESSAGE['MEDIA']['CONFIRM_DELETE'] |
Also available in: Unified diff
- Added posibility to upload and unzip .zip packages to media section (Thanks to BerndJM)
- Updated Browse Media Window in wb_theme now supports file icons, more file informations and a new preview function (Thanks to BerndJM)