[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[270] | 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | |
---|
| 13 | /* HTML page |
---|
| 14 | -------------------------------------------------------- */ |
---|
| 15 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 16 | |
---|
| 17 | dcPage::check('media,media_admin'); |
---|
| 18 | |
---|
| 19 | $post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null; |
---|
| 20 | if ($post_id) { |
---|
[408] | 21 | $post = $core->blog->getPosts(array('post_id'=>$post_id,'post_type'=>'')); |
---|
[0] | 22 | if ($post->isEmpty()) { |
---|
| 23 | $post_id = null; |
---|
| 24 | } |
---|
| 25 | $post_title = $post->post_title; |
---|
| 26 | $post_type = $post->post_type; |
---|
| 27 | unset($post); |
---|
| 28 | } |
---|
| 29 | $d = isset($_REQUEST['d']) ? $_REQUEST['d'] : null; |
---|
| 30 | $dir = null; |
---|
| 31 | |
---|
| 32 | $page = !empty($_GET['page']) ? $_GET['page'] : 1; |
---|
| 33 | $nb_per_page = 30; |
---|
| 34 | |
---|
| 35 | # We are on home not comming from media manager |
---|
| 36 | if ($d === null && isset($_SESSION['media_manager_dir'])) { |
---|
| 37 | # We get session information |
---|
| 38 | $d = $_SESSION['media_manager_dir']; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | if (!isset($_GET['page']) && isset($_SESSION['media_manager_page'])) { |
---|
| 42 | $page = $_SESSION['media_manager_page']; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | # We set session information about directory and page |
---|
| 46 | if ($d) { |
---|
| 47 | $_SESSION['media_manager_dir'] = $d; |
---|
| 48 | } else { |
---|
| 49 | unset($_SESSION['media_manager_dir']); |
---|
| 50 | } |
---|
| 51 | if ($page != 1) { |
---|
| 52 | $_SESSION['media_manager_page'] = $page; |
---|
| 53 | } else { |
---|
| 54 | unset($_SESSION['media_manager_page']); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | # Sort combo |
---|
| 58 | $sort_combo = array( |
---|
| 59 | __('By names, in ascending order') => 'name-asc', |
---|
| 60 | __('By names, in descending order') => 'name-desc', |
---|
| 61 | __('By dates, in ascending order') => 'date-asc', |
---|
| 62 | __('By dates, in descending order') => 'date-desc' |
---|
[1161] | 63 | ); |
---|
[0] | 64 | |
---|
| 65 | if (!empty($_GET['file_sort']) && in_array($_GET['file_sort'],$sort_combo)) { |
---|
| 66 | $_SESSION['media_file_sort'] = $_GET['file_sort']; |
---|
| 67 | } |
---|
| 68 | $file_sort = !empty($_SESSION['media_file_sort']) ? $_SESSION['media_file_sort'] : null; |
---|
| 69 | |
---|
| 70 | $popup = (integer) !empty($_GET['popup']); |
---|
| 71 | |
---|
| 72 | $page_url = 'media.php?popup='.$popup.'&post_id='.$post_id; |
---|
| 73 | |
---|
| 74 | if ($popup) { |
---|
| 75 | $open_f = array('dcPage','openPopup'); |
---|
| 76 | $close_f = array('dcPage','closePopup'); |
---|
| 77 | } else { |
---|
| 78 | $open_f = array('dcPage','open'); |
---|
| 79 | $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | $core_media_writable = false; |
---|
| 83 | try { |
---|
| 84 | $core->media = new dcMedia($core); |
---|
| 85 | if ($file_sort) { |
---|
| 86 | $core->media->setFileSort($file_sort); |
---|
| 87 | } |
---|
| 88 | $core->media->chdir($d); |
---|
| 89 | $core->media->getDir(); |
---|
| 90 | $core_media_writable = $core->media->writable(); |
---|
| 91 | $dir =& $core->media->dir; |
---|
| 92 | if (!$core_media_writable) { |
---|
| 93 | throw new Exception('you do not have sufficient permissions to write to this folder: '); |
---|
| 94 | } |
---|
| 95 | } catch (Exception $e) { |
---|
| 96 | $core->error->add($e->getMessage()); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | # Zip download |
---|
| 100 | if (!empty($_GET['zipdl']) && $core->auth->check('media_admin',$core->blog->id)) |
---|
| 101 | { |
---|
| 102 | try |
---|
| 103 | { |
---|
| 104 | @set_time_limit(300); |
---|
| 105 | $fp = fopen('php://output','wb'); |
---|
| 106 | $zip = new fileZip($fp); |
---|
| 107 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); |
---|
| 108 | $zip->addDirectory($core->media->root.'/'.$d,'',true); |
---|
| 109 | |
---|
| 110 | header('Content-Disposition: attachment;filename='.($d ? $d : 'media').'.zip'); |
---|
| 111 | header('Content-Type: application/x-zip'); |
---|
| 112 | $zip->write(); |
---|
| 113 | unset($zip); |
---|
| 114 | exit; |
---|
| 115 | } |
---|
| 116 | catch (Exception $e) |
---|
| 117 | { |
---|
| 118 | $core->error->add($e->getMessage()); |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | # New directory |
---|
| 123 | if ($dir && !empty($_POST['newdir'])) |
---|
| 124 | { |
---|
| 125 | try { |
---|
| 126 | $core->media->makeDir($_POST['newdir']); |
---|
| 127 | http::redirect($page_url.'&d='.rawurlencode($d).'&mkdok=1'); |
---|
| 128 | } catch (Exception $e) { |
---|
| 129 | $core->error->add($e->getMessage()); |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | # Adding a file |
---|
[1159] | 134 | if ($dir && !empty($_FILES['upfile'])) { |
---|
| 135 | // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload |
---|
[1161] | 136 | $upfile = array('name' => $_FILES['upfile']['name'][0], |
---|
| 137 | 'type' => $_FILES['upfile']['type'][0], |
---|
| 138 | 'tmp_name' => $_FILES['upfile']['tmp_name'][0], |
---|
| 139 | 'error' => $_FILES['upfile']['error'][0], |
---|
| 140 | 'size' => $_FILES['upfile']['size'][0] |
---|
| 141 | ); |
---|
[1144] | 142 | |
---|
[1161] | 143 | if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
---|
| 144 | header('Content-type: application/json'); |
---|
| 145 | $message = array(); |
---|
[1144] | 146 | |
---|
[1161] | 147 | try { |
---|
| 148 | files::uploadStatus($upfile); |
---|
| 149 | $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']); |
---|
[1144] | 150 | |
---|
[1161] | 151 | $message['files'][] = array('name' => $upfile['name'], |
---|
| 152 | 'size' => $upfile['size'], |
---|
| 153 | 'html' => mediaItemLine($core->media->getFile($new_file_id), 1) |
---|
| 154 | ); |
---|
| 155 | } catch (Exception $e) { |
---|
| 156 | $message['files'][] = array('name' => $upfile['name'], |
---|
[1162] | 157 | 'size' => $upfile['size'], |
---|
[1161] | 158 | 'error' => $e->getMessage() |
---|
| 159 | ); |
---|
| 160 | } |
---|
| 161 | echo json_encode($message); |
---|
| 162 | exit(); |
---|
| 163 | } else { |
---|
| 164 | try { |
---|
| 165 | files::uploadStatus($upfile); |
---|
[1159] | 166 | |
---|
[1161] | 167 | $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''); |
---|
| 168 | $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); |
---|
[1159] | 169 | |
---|
[1161] | 170 | $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private); |
---|
| 171 | http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); |
---|
| 172 | } catch (Exception $e) { |
---|
| 173 | $core->error->add($e->getMessage()); |
---|
| 174 | } |
---|
| 175 | } |
---|
[0] | 176 | } |
---|
| 177 | |
---|
| 178 | # Removing item |
---|
| 179 | if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) |
---|
| 180 | { |
---|
| 181 | $_POST['remove'] = rawurldecode($_POST['remove']); |
---|
| 182 | |
---|
| 183 | try { |
---|
| 184 | $core->media->removeItem($_POST['remove']); |
---|
| 185 | http::redirect($page_url.'&d='.rawurlencode($d).'&rmfok=1'); |
---|
| 186 | } catch (Exception $e) { |
---|
| 187 | $core->error->add($e->getMessage()); |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | # Rebuild directory |
---|
| 192 | if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) |
---|
| 193 | { |
---|
| 194 | try { |
---|
| 195 | $core->media->rebuild($d); |
---|
| 196 | http::redirect($page_url.'&d='.rawurlencode($d).'&rebuildok=1'); |
---|
| 197 | } catch (Exception $e) { |
---|
| 198 | $core->error->add($e->getMessage()); |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | # DISPLAY confirm page for rmdir & rmfile |
---|
[947] | 203 | if ($dir && !empty($_GET['remove']) && empty($_GET['noconfirm'])) |
---|
[0] | 204 | { |
---|
| 205 | call_user_func($open_f,__('Media manager')); |
---|
| 206 | |
---|
[500] | 207 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Media manager').' › <span class="page-title">'.__('confirm removal').'</span></h2>'; |
---|
[0] | 208 | |
---|
| 209 | echo |
---|
| 210 | '<form action="'.html::escapeURL($page_url).'" method="post">'. |
---|
| 211 | '<p>'.sprintf(__('Are you sure you want to remove %s?'), |
---|
[1161] | 212 | html::escapeHTML($_GET['remove'])).'</p>'. |
---|
[557] | 213 | '<p><input type="submit" value="'.__('Cancel').'" /> '. |
---|
| 214 | ' <input type="submit" name="rmyes" value="'.__('Yes').'" />'. |
---|
[0] | 215 | form::hidden('d',$d). |
---|
| 216 | $core->formNonce(). |
---|
| 217 | form::hidden('remove',html::escapeHTML($_GET['remove'])).'</p>'. |
---|
| 218 | '</form>'; |
---|
| 219 | |
---|
| 220 | call_user_func($close_f); |
---|
| 221 | exit; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | /* DISPLAY Main page |
---|
| 225 | -------------------------------------------------------- */ |
---|
[240] | 226 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 227 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
| 228 | |
---|
[0] | 229 | call_user_func($open_f,__('Media manager'), |
---|
| 230 | dcPage::jsLoad('js/_media.js'). |
---|
[1144] | 231 | ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : '') |
---|
[240] | 232 | ); |
---|
[0] | 233 | |
---|
| 234 | if (!empty($_GET['mkdok'])) { |
---|
[907] | 235 | dcPage::message(__('Directory has been successfully created.')); |
---|
[0] | 236 | } |
---|
| 237 | |
---|
| 238 | if (!empty($_GET['upok'])) { |
---|
[907] | 239 | dcPage::message(__('Files have been successfully uploaded.')); |
---|
[0] | 240 | } |
---|
| 241 | |
---|
| 242 | if (!empty($_GET['rmfok'])) { |
---|
[907] | 243 | dcPage::message(__('File has been successfully removed.')); |
---|
[0] | 244 | } |
---|
| 245 | |
---|
| 246 | if (!empty($_GET['rmdok'])) { |
---|
[907] | 247 | dcPage::message(__('Directory has been successfully removed.')); |
---|
[0] | 248 | } |
---|
| 249 | |
---|
| 250 | if (!empty($_GET['rebuildok'])) { |
---|
[907] | 251 | dcPage::message(__('Directory has been successfully rebuilt.')); |
---|
[0] | 252 | } |
---|
| 253 | |
---|
| 254 | if (!empty($_GET['unzipok'])) { |
---|
[907] | 255 | dcPage::message(__('Zip file has been successfully extracted.')); |
---|
[0] | 256 | } |
---|
| 257 | |
---|
[505] | 258 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '; |
---|
| 259 | if (!isset($core->media)) { |
---|
| 260 | echo '<span class="page-title">'.__('Media manager').'</span></h2>'; |
---|
| 261 | } else { |
---|
| 262 | $breadcrumb = $core->media->breadCrumb(html::escapeURL($page_url).'&d=%s','<span class="page-title">%s</span>'); |
---|
| 263 | if ($breadcrumb == '') { |
---|
| 264 | echo '<span class="page-title">'.__('Media manager').'</span></h2>'; |
---|
| 265 | } else { |
---|
| 266 | echo '<a href="'.html::escapeURL($page_url.'&d=').'">'.__('Media manager').'</a>'.' / '.$breadcrumb.'</h2>'; |
---|
| 267 | } |
---|
| 268 | } |
---|
[0] | 269 | |
---|
| 270 | if (!$dir) { |
---|
| 271 | call_user_func($close_f); |
---|
| 272 | exit; |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | if ($post_id) { |
---|
| 276 | echo '<p><strong>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s.'), |
---|
[1161] | 277 | '<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>', |
---|
| 278 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</strong></p>'; |
---|
[0] | 279 | } |
---|
| 280 | if ($popup) { |
---|
| 281 | echo '<p><strong>'.sprintf(__('Choose a file to insert into entry by clicking on %s.'), |
---|
[1161] | 282 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</strong></p>'; |
---|
[0] | 283 | } |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | $items = array_values(array_merge($dir['dirs'],$dir['files'])); |
---|
[1160] | 287 | echo '<div class="media-list">'; |
---|
[0] | 288 | if (count($items) == 0) |
---|
| 289 | { |
---|
| 290 | echo '<p><strong>'.__('No file.').'</strong></p>'; |
---|
| 291 | } |
---|
| 292 | else |
---|
| 293 | { |
---|
| 294 | $pager = new pager($page,count($items),$nb_per_page,10); |
---|
| 295 | $pager->html_prev = __($pager->html_prev); |
---|
| 296 | $pager->html_next = __($pager->html_next); |
---|
| 297 | |
---|
| 298 | echo |
---|
| 299 | '<form action="media.php" method="get">'. |
---|
[68] | 300 | '<p><label for="file_sort" class="classic">'.__('Sort files:').' '. |
---|
[0] | 301 | form::combo('file_sort',$sort_combo,$file_sort).'</label>'. |
---|
| 302 | form::hidden(array('popup'),$popup). |
---|
| 303 | form::hidden(array('post_id'),$post_id). |
---|
[557] | 304 | '<input type="submit" value="'.__('Sort').'" /></p>'. |
---|
[0] | 305 | '</form>'. |
---|
| 306 | |
---|
| 307 | '<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
| 308 | |
---|
| 309 | for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++, $j++) |
---|
| 310 | { |
---|
| 311 | echo mediaItemLine($items[$i],$j); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | echo |
---|
[1161] | 315 | '<p class="clear">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; |
---|
[0] | 316 | } |
---|
[1162] | 317 | if (!isset($pager)) { |
---|
| 318 | echo |
---|
| 319 | '<p class="clear"></p>'; |
---|
| 320 | } |
---|
[1160] | 321 | echo |
---|
[1161] | 322 | '</div>'; |
---|
[1144] | 323 | |
---|
[0] | 324 | if ($core_media_writable) |
---|
| 325 | { |
---|
[1161] | 326 | echo '<div class="two-cols">'; |
---|
[0] | 327 | |
---|
[1161] | 328 | if ($user_ui_enhanceduploader) { |
---|
| 329 | echo |
---|
| 330 | '<div class="col enhanced_uploader">'; |
---|
| 331 | } else { |
---|
| 332 | echo |
---|
| 333 | '<div class="col">'; |
---|
| 334 | } |
---|
[1159] | 335 | |
---|
[1161] | 336 | echo |
---|
| 337 | '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'. |
---|
| 338 | '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. |
---|
| 339 | ' <form id="fileupload" action="'.html::escapeURL($page_url).'" method="POST" enctype="multipart/form-data">'. |
---|
| 340 | '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). |
---|
[1162] | 341 | $core->formNonce().'</div>'. |
---|
| 342 | '<div class="fileupload-ctrl"><div class="files"></div></div>'; |
---|
[1159] | 343 | |
---|
[1161] | 344 | echo |
---|
[1162] | 345 | '<div class="fileupload-buttonbar">'; |
---|
| 346 | |
---|
| 347 | echo |
---|
| 348 | '<span class="max-size"> ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')</span>'. |
---|
[1163] | 349 | '<label for="upfile">'. |
---|
| 350 | '<span class="add-label one-file">'.__('Choose file').'</span>'. |
---|
| 351 | '<button class="button add">'.__('Choose files').'</button>'. |
---|
[1161] | 352 | '<input type="file" id="upfile" name="upfile[]"'.($user_ui_enhanceduploader?' multiple="mutiple"':'').' data-url="'.html::escapeURL($page_url).'" />'. |
---|
[1163] | 353 | '</label>'; |
---|
[1159] | 354 | |
---|
[1161] | 355 | echo |
---|
| 356 | '<p class="one-file"><label for="upfiletitle">'.__('Title:').form::field(array('upfiletitle','upfiletitle'),35,255).'</label></p>'. |
---|
| 357 | '<p class="one-file"><label for="upfilepriv" class="classic">'.form::checkbox(array('upfilepriv','upfilepriv'),1).' '. |
---|
| 358 | __('Private').'</label></p>'; |
---|
[1159] | 359 | |
---|
[1161] | 360 | if (!$user_ui_enhanceduploader) { |
---|
| 361 | echo |
---|
| 362 | '<p class="one-file form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). |
---|
| 363 | ' <a href="preferences.php?tab=user-options">'.__('My preferences').'</a></p>'; |
---|
| 364 | } |
---|
[1159] | 365 | |
---|
[1161] | 366 | echo |
---|
[1162] | 367 | '<button class="button clean">'.__('Clean').'</button>'. |
---|
[1164] | 368 | '<input class="button cancel one-file" type="reset" value="'.__('Cancel').'"/>'. |
---|
[1161] | 369 | '<input class="button start" type="submit" value="'.__('Send').'"/>'. |
---|
| 370 | '</div>'; |
---|
[1159] | 371 | |
---|
[1161] | 372 | echo |
---|
| 373 | '<div>'.form::hidden(array('d'),$d).'</div>'. |
---|
| 374 | '</fieldset>'. |
---|
| 375 | '</form>'. |
---|
| 376 | '</div>'; |
---|
[0] | 377 | |
---|
| 378 | echo |
---|
[536] | 379 | '<div class="col">'. |
---|
[0] | 380 | '<form class="clear" action="'.html::escapeURL($page_url).'" method="post">'. |
---|
| 381 | '<fieldset id="new-dir-f">'. |
---|
[536] | 382 | '<legend>'.__('New directory').'</legend>'. |
---|
[0] | 383 | $core->formNonce(). |
---|
[68] | 384 | '<p><label for="newdir">'.__('Directory Name:'). |
---|
[235] | 385 | form::field(array('newdir','newdir'),35,255).'</label></p>'. |
---|
[557] | 386 | '<p><input type="submit" value="'.__('Create').'" />'. |
---|
[0] | 387 | form::hidden(array('d'),html::escapeHTML($d)).'</p>'. |
---|
| 388 | '</fieldset>'. |
---|
| 389 | '</form></div>'; |
---|
| 390 | |
---|
| 391 | echo '</div>'; |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | # Empty remove form (for javascript actions) |
---|
| 395 | echo |
---|
| 396 | '<form id="media-remove-hide" action="'.html::escapeURL($page_url).'" method="post"><div class="clear">'. |
---|
| 397 | form::hidden('rmyes',1).form::hidden('d',html::escapeHTML($d)). |
---|
| 398 | form::hidden('remove',''). |
---|
| 399 | $core->formNonce(). |
---|
| 400 | '</div></form>'; |
---|
| 401 | |
---|
| 402 | # Get zip directory |
---|
| 403 | if ($core->auth->check('media_admin',$core->blog->id) && |
---|
| 404 | !(count($items) == 0 || (count($items) == 1 && $items[0]->parent))) |
---|
| 405 | { |
---|
| 406 | echo |
---|
| 407 | '<p class="zip-dl"><a href="'.html::escapeURL($page_url).'&zipdl=1">'. |
---|
| 408 | __('Download this directory as a zip file').'</a></p>'; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | call_user_func($close_f); |
---|
| 412 | |
---|
| 413 | /* ----------------------------------------------------- */ |
---|
| 414 | function mediaItemLine($f,$i) |
---|
| 415 | { |
---|
| 416 | global $core, $page_url, $popup, $post_id; |
---|
| 417 | |
---|
| 418 | $fname = $f->basename; |
---|
| 419 | |
---|
| 420 | if ($f->d) { |
---|
| 421 | $link = html::escapeURL($page_url).'&d='.html::sanitizeURL($f->relname); |
---|
| 422 | if ($f->parent) { |
---|
| 423 | $fname = '..'; |
---|
| 424 | } |
---|
| 425 | } else { |
---|
| 426 | $link = |
---|
| 427 | 'media_item.php?id='.$f->media_id.'&popup='.$popup.'&post_id='.$post_id; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | $class = 'media-item media-col-'.($i%2); |
---|
| 431 | |
---|
| 432 | $res = |
---|
| 433 | '<div class="'.$class.'"><a class="media-icon media-link" href="'.$link.'">'. |
---|
| 434 | '<img src="'.$f->media_icon.'" alt="" /></a>'. |
---|
| 435 | '<ul>'. |
---|
| 436 | '<li><a class="media-link" href="'.$link.'">'.$fname.'</a></li>'; |
---|
| 437 | |
---|
| 438 | if (!$f->d) { |
---|
| 439 | $res .= |
---|
| 440 | '<li>'.$f->media_title.'</li>'. |
---|
| 441 | '<li>'. |
---|
| 442 | $f->media_dtstr.' - '. |
---|
| 443 | files::size($f->size).' - '. |
---|
| 444 | '<a href="'.$f->file_url.'">'.__('open').'</a>'. |
---|
| 445 | '</li>'; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | $res .= '<li class="media-action"> '; |
---|
| 449 | |
---|
| 450 | if ($post_id && !$f->d) { |
---|
| 451 | $res .= '<form action="post_media.php" method="post">'. |
---|
| 452 | '<input type="image" src="images/plus.png" alt="'.__('Attach this file to entry').'" '. |
---|
| 453 | 'title="'.__('Attach this file to entry').'" /> '. |
---|
| 454 | form::hidden('media_id',$f->media_id). |
---|
| 455 | form::hidden('post_id',$post_id). |
---|
| 456 | form::hidden('attach',1). |
---|
| 457 | $core->formNonce(). |
---|
| 458 | '</form>'; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | if ($popup && !$f->d) { |
---|
| 462 | $res .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. |
---|
| 463 | 'title="'.__('Insert this file into entry').'" /></a> '; |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | if ($f->del) { |
---|
| 467 | $res .= '<a class="media-remove" '. |
---|
| 468 | 'href="'.html::escapeURL($page_url).'&d='. |
---|
| 469 | rawurlencode($GLOBALS['d']).'&remove='.rawurlencode($f->basename).'">'. |
---|
[747] | 470 | '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>'; |
---|
[0] | 471 | } |
---|
| 472 | |
---|
| 473 | $res .= '</li>'; |
---|
| 474 | |
---|
| 475 | if ($f->type == 'audio/mpeg3') { |
---|
| 476 | $res .= '<li>'.dcMedia::mp3player($f->file_url,'index.php?pf=player_mp3.swf').'</li>'; |
---|
| 477 | } |
---|
| 478 | |
---|
| 479 | $res .= '</ul></div>'; |
---|
| 480 | |
---|
| 481 | return $res; |
---|
| 482 | } |
---|
| 483 | ?> |
---|