[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 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 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::check('media,media_admin'); |
---|
| 16 | |
---|
[861] | 17 | $tab = empty($_REQUEST['tab']) ? '' : $_REQUEST['tab']; |
---|
| 18 | |
---|
[0] | 19 | $post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null; |
---|
| 20 | if ($post_id) { |
---|
| 21 | $post = $core->blog->getPosts(array('post_id'=>$post_id)); |
---|
| 22 | if ($post->isEmpty()) { |
---|
| 23 | $post_id = null; |
---|
| 24 | } |
---|
| 25 | $post_title = $post->post_title; |
---|
| 26 | unset($post); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | $file = null; |
---|
| 30 | $popup = (integer) !empty($_GET['popup']); |
---|
| 31 | $page_url = 'media_item.php?popup='.$popup.'&post_id='.$post_id; |
---|
| 32 | $media_page_url = 'media.php?popup='.$popup.'&post_id='.$post_id; |
---|
| 33 | |
---|
| 34 | $id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : ''; |
---|
| 35 | |
---|
| 36 | if ($popup) { |
---|
| 37 | $open_f = array('dcPage','openPopup'); |
---|
| 38 | $close_f = array('dcPage','closePopup'); |
---|
| 39 | } else { |
---|
| 40 | $open_f = array('dcPage','open'); |
---|
| 41 | $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | $core_media_writable = false; |
---|
| 45 | try |
---|
| 46 | { |
---|
| 47 | $core->media = new dcMedia($core); |
---|
| 48 | |
---|
| 49 | if ($id) { |
---|
| 50 | $file = $core->media->getFile($id); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | if ($file === null) { |
---|
| 54 | throw new Exception(__('Not a valid file')); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | $core->media->chdir(dirname($file->relname)); |
---|
| 58 | $core_media_writable = $core->media->writable(); |
---|
| 59 | |
---|
| 60 | # Prepare directories combo box |
---|
| 61 | $dirs_combo = array(); |
---|
[1103] | 62 | foreach ($core->media->getDBDirs() as $v) { |
---|
| 63 | $dirs_combo['/'.$v] = $v; |
---|
[0] | 64 | } |
---|
[2098] | 65 | # Add parent and direct childs directories if any |
---|
| 66 | $core->media->getFSDir(); |
---|
| 67 | foreach ($core->media->dir['dirs'] as $k => $v) { |
---|
| 68 | $dirs_combo['/'.$v->relname] = $v->relname; |
---|
| 69 | } |
---|
[0] | 70 | ksort($dirs_combo); |
---|
| 71 | } |
---|
| 72 | catch (Exception $e) |
---|
| 73 | { |
---|
| 74 | $core->error->add($e->getMessage()); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | # Upload a new file |
---|
| 78 | if ($file && !empty($_FILES['upfile']) && $file->editable && $core_media_writable) |
---|
| 79 | { |
---|
| 80 | try { |
---|
| 81 | files::uploadStatus($_FILES['upfile']); |
---|
| 82 | $core->media->uploadFile($_FILES['upfile']['tmp_name'],$file->basename,null,false,true); |
---|
| 83 | http::redirect($page_url.'&id='.$id.'&fupl=1'); |
---|
| 84 | } catch (Exception $e) { |
---|
| 85 | $core->error->add($e->getMessage()); |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | # Update file |
---|
| 90 | if ($file && !empty($_POST['media_file']) && $file->editable && $core_media_writable) |
---|
| 91 | { |
---|
| 92 | $newFile = clone $file; |
---|
| 93 | |
---|
| 94 | $newFile->basename = $_POST['media_file']; |
---|
| 95 | |
---|
| 96 | if ($_POST['media_path']) { |
---|
| 97 | $newFile->dir = $_POST['media_path']; |
---|
| 98 | $newFile->relname = $_POST['media_path'].'/'.$newFile->basename; |
---|
| 99 | } else { |
---|
| 100 | $newFile->dir = ''; |
---|
| 101 | $newFile->relname = $newFile->basename; |
---|
| 102 | } |
---|
| 103 | $newFile->media_title = $_POST['media_title']; |
---|
| 104 | $newFile->media_dt = strtotime($_POST['media_dt']); |
---|
| 105 | $newFile->media_dtstr = $_POST['media_dt']; |
---|
| 106 | $newFile->media_priv = !empty($_POST['media_private']); |
---|
| 107 | |
---|
| 108 | try { |
---|
| 109 | $core->media->updateFile($file,$newFile); |
---|
[861] | 110 | http::redirect($page_url.'&id='.$id.'&fupd=1&tab=media-details-tab'); |
---|
[0] | 111 | } catch (Exception $e) { |
---|
| 112 | $core->error->add($e->getMessage()); |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | # Update thumbnails |
---|
| 117 | if (!empty($_POST['thumbs']) && $file->media_type == 'image' && $file->editable && $core_media_writable) |
---|
| 118 | { |
---|
| 119 | try { |
---|
| 120 | $foo = null; |
---|
[2] | 121 | $core->media->mediaFireRecreateEvent($file); |
---|
[861] | 122 | http::redirect($page_url.'&id='.$id.'&thumbupd=1&tab=media-details-tab'); |
---|
[0] | 123 | } catch (Exception $e) { |
---|
| 124 | $core->error->add($e->getMessage()); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | # Unzip file |
---|
| 129 | if (!empty($_POST['unzip']) && $file->type == 'application/zip' && $file->editable && $core_media_writable) |
---|
| 130 | { |
---|
| 131 | try { |
---|
| 132 | $unzip_dir = $core->media->inflateZipFile($file,$_POST['inflate_mode'] == 'new'); |
---|
| 133 | http::redirect($media_page_url.'&d='.$unzip_dir.'&unzipok=1'); |
---|
| 134 | } catch (Exception $e) { |
---|
| 135 | $core->error->add($e->getMessage()); |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | |
---|
[2093] | 139 | # Save media insertion settings for the blog |
---|
| 140 | if (!empty($_POST['save_blog_prefs'])) |
---|
| 141 | { |
---|
| 142 | if (!empty($_POST['pref_src'])) { |
---|
| 143 | foreach (array_reverse($file->media_thumb) as $s => $v) { |
---|
| 144 | if ($v == $_POST['pref_src']) { |
---|
| 145 | $core->blog->settings->system->put('media_img_default_size',$s); |
---|
| 146 | break; |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | if (!empty($_POST['pref_alignment'])) { |
---|
| 151 | $core->blog->settings->system->put('media_img_default_alignment',$_POST['pref_alignment']); |
---|
| 152 | } |
---|
| 153 | if (!empty($_POST['pref_insertion'])) { |
---|
| 154 | $core->blog->settings->system->put('media_img_default_link',($_POST['pref_insertion'] == 'link')); |
---|
| 155 | } |
---|
| 156 | http::redirect($page_url.'&id='.$id.'&blogprefupd=1'); |
---|
| 157 | } |
---|
| 158 | |
---|
[0] | 159 | # Function to get image title based on meta |
---|
[1073] | 160 | function dcGetImageTitle($file,$pattern,$dto_first=false) |
---|
[0] | 161 | { |
---|
| 162 | $res = array(); |
---|
| 163 | $pattern = preg_split('/\s*;;\s*/',$pattern); |
---|
| 164 | $sep = ', '; |
---|
| 165 | |
---|
| 166 | foreach ($pattern as $v) { |
---|
| 167 | if ($v == 'Title') { |
---|
| 168 | $res[] = $file->media_title; |
---|
| 169 | } elseif ($file->media_meta->{$v}) { |
---|
| 170 | $res[] = (string) $file->media_meta->{$v}; |
---|
| 171 | } elseif (preg_match('/^Date\((.+?)\)$/u',$v,$m)) { |
---|
[1121] | 172 | if ($dto_first && ($file->media_meta->DateTimeOriginal != 0)) { |
---|
[1073] | 173 | $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal); |
---|
| 174 | } else { |
---|
| 175 | $res[] = dt::str($m[1],$file->media_dt); |
---|
| 176 | } |
---|
[0] | 177 | } elseif (preg_match('/^DateTimeOriginal\((.+?)\)$/u',$v,$m) && $file->media_meta->DateTimeOriginal) { |
---|
| 178 | $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal); |
---|
| 179 | } elseif (preg_match('/^separator\((.*?)\)$/u',$v,$m)) { |
---|
| 180 | $sep = $m[1]; |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | return implode($sep,$res); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | /* DISPLAY Main page |
---|
| 187 | -------------------------------------------------------- */ |
---|
[947] | 188 | $starting_scripts = |
---|
| 189 | '<script type="text/javascript">'."\n". |
---|
| 190 | "//<![CDATA["."\n". |
---|
| 191 | dcPage::jsVar('dotclear.msg.confirm_delete_media',__('Are you sure to delete this media?'))."\n". |
---|
| 192 | "//]]>". |
---|
| 193 | "</script>". |
---|
| 194 | dcPage::jsLoad('js/_media_item.js'); |
---|
[0] | 195 | if ($popup) { |
---|
| 196 | $starting_scripts .= |
---|
| 197 | dcPage::jsLoad('js/jsToolBar/popup_media.js'); |
---|
| 198 | } |
---|
| 199 | call_user_func($open_f,__('Media manager'), |
---|
| 200 | $starting_scripts. |
---|
| 201 | dcPage::jsDatePicker(). |
---|
[1996] | 202 | ($popup ? dcPage::jsPageTabs($tab) : ''), |
---|
[1358] | 203 | dcPage::breadcrumb( |
---|
| 204 | array( |
---|
| 205 | html::escapeHTML($core->blog->name) => '', |
---|
| 206 | __('Media manager') => html::escapeURL($media_page_url), |
---|
| 207 | $core->media->breadCrumb(html::escapeURL($media_page_url).'&d=%s').'<span class="page-title">'.$file->basename.'</span>' => '' |
---|
[2166] | 208 | ), |
---|
| 209 | array( |
---|
| 210 | 'home_link' => !$popup, |
---|
[2167] | 211 | 'hl' => false |
---|
[2166] | 212 | ) |
---|
| 213 | ) |
---|
[0] | 214 | ); |
---|
| 215 | |
---|
| 216 | if ($file === null) { |
---|
| 217 | call_user_func($close_f); |
---|
| 218 | exit; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | if (!empty($_GET['fupd']) || !empty($_GET['fupl'])) { |
---|
[1553] | 222 | dcPage::success(__('File has been successfully updated.')); |
---|
[0] | 223 | } |
---|
| 224 | if (!empty($_GET['thumbupd'])) { |
---|
[1553] | 225 | dcPage::success(__('Thumbnails have been successfully updated.')); |
---|
[0] | 226 | } |
---|
[2093] | 227 | if (!empty($_GET['blogprefupd'])) { |
---|
| 228 | dcPage::success(__('Default media insertion settings have been successfully updated.')); |
---|
| 229 | } |
---|
[0] | 230 | |
---|
| 231 | # Insertion popup |
---|
| 232 | if ($popup) |
---|
| 233 | { |
---|
| 234 | $media_desc = $file->media_title; |
---|
| 235 | |
---|
| 236 | echo |
---|
| 237 | '<div id="media-insert" class="multi-part" title="'.__('Insert media item').'">'. |
---|
[2003] | 238 | '<h3>'.__('Insert media item').'</h3>'. |
---|
[0] | 239 | '<form id="media-insert-form" action="" method="get">'; |
---|
| 240 | |
---|
[950] | 241 | $media_img_default_size = $core->blog->settings->system->media_img_default_size; |
---|
| 242 | if ($media_img_default_size == '') { |
---|
| 243 | $media_img_default_size = 'm'; |
---|
| 244 | } |
---|
| 245 | $media_img_default_alignment = $core->blog->settings->system->media_img_default_alignment; |
---|
| 246 | if ($media_img_default_alignment == '') { |
---|
| 247 | $media_img_default_alignment = 'none'; |
---|
| 248 | } |
---|
| 249 | $media_img_default_link = (boolean)$core->blog->settings->system->media_img_default_link; |
---|
| 250 | |
---|
[0] | 251 | if ($file->media_type == 'image') |
---|
| 252 | { |
---|
| 253 | $media_type = 'image'; |
---|
[1073] | 254 | $media_desc = dcGetImageTitle($file, |
---|
| 255 | $core->blog->settings->system->media_img_title_pattern, |
---|
| 256 | $core->blog->settings->system->media_img_use_dto_first); |
---|
[0] | 257 | if ($media_desc == $file->basename) { |
---|
| 258 | $media_desc = ''; |
---|
| 259 | } |
---|
[887] | 260 | |
---|
[0] | 261 | echo |
---|
| 262 | '<h3>'.__('Image size:').'</h3> '; |
---|
| 263 | |
---|
| 264 | $s_checked = false; |
---|
| 265 | echo '<p>'; |
---|
| 266 | foreach (array_reverse($file->media_thumb) as $s => $v) { |
---|
[887] | 267 | $s_checked = ($s == $media_img_default_size); |
---|
[0] | 268 | echo '<label class="classic">'. |
---|
| 269 | form::radio(array('src'),html::escapeHTML($v),$s_checked).' '. |
---|
| 270 | $core->media->thumb_sizes[$s][2].'</label><br /> '; |
---|
| 271 | } |
---|
[887] | 272 | $s_checked = (!isset($file->media_thumb[$media_img_default_size])); |
---|
[0] | 273 | echo '<label class="classic">'. |
---|
| 274 | form::radio(array('src'),$file->file_url,$s_checked).' '.__('original').'</label><br /> '; |
---|
| 275 | echo '</p>'; |
---|
| 276 | |
---|
| 277 | |
---|
| 278 | echo '<h3>'.__('Image alignment').'</h3>'; |
---|
| 279 | $i_align = array( |
---|
[887] | 280 | 'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)), |
---|
| 281 | 'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)), |
---|
| 282 | 'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)), |
---|
| 283 | 'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0)) |
---|
[0] | 284 | ); |
---|
| 285 | |
---|
| 286 | echo '<p>'; |
---|
| 287 | foreach ($i_align as $k => $v) { |
---|
| 288 | echo '<label class="classic">'. |
---|
| 289 | form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; |
---|
| 290 | } |
---|
| 291 | echo '</p>'; |
---|
| 292 | |
---|
| 293 | echo |
---|
| 294 | '<h3>'.__('Image insertion').'</h3>'. |
---|
| 295 | '<p>'. |
---|
[887] | 296 | '<label for="insert1" class="classic">'.form::radio(array('insertion','insert1'),'simple',!$media_img_default_link). |
---|
[0] | 297 | __('As a single image').'</label><br />'. |
---|
[887] | 298 | '<label for="insert2" class="classic">'.form::radio(array('insertion','insert2'),'link',$media_img_default_link). |
---|
[1853] | 299 | __('As a link to the original image').'</label>'. |
---|
[0] | 300 | '</p>'; |
---|
| 301 | } |
---|
| 302 | elseif ($file->type == 'audio/mpeg3') |
---|
| 303 | { |
---|
| 304 | $media_type = 'mp3'; |
---|
| 305 | |
---|
[907] | 306 | echo '<h3>'.__('MP3 disposition').'</h3>'; |
---|
| 307 | dcPage::message(__("Please note that you cannot insert mp3 files with visual editor."),false); |
---|
[0] | 308 | |
---|
| 309 | $i_align = array( |
---|
[950] | 310 | 'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)), |
---|
| 311 | 'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)), |
---|
| 312 | 'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)), |
---|
| 313 | 'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0)) |
---|
[0] | 314 | ); |
---|
| 315 | |
---|
| 316 | echo '<p>'; |
---|
| 317 | foreach ($i_align as $k => $v) { |
---|
[1853] | 318 | echo '<label class="classic">'. |
---|
[0] | 319 | form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | $public_player_style = unserialize($core->blog->settings->themes->mp3player_style); |
---|
| 323 | $public_player = dcMedia::mp3player($file->file_url,$core->blog->getQmarkURL().'pf=player_mp3.swf',$public_player_style); |
---|
| 324 | echo form::hidden('public_player',html::escapeHTML($public_player)); |
---|
| 325 | echo '</p>'; |
---|
| 326 | } |
---|
| 327 | elseif ($file->type == 'video/x-flv' || $file->type == 'video/mp4' || $file->type == 'video/x-m4v') |
---|
| 328 | { |
---|
| 329 | $media_type = 'flv'; |
---|
| 330 | |
---|
[907] | 331 | dcPage::message(__("Please note that you cannot insert video files with visual editor."),false); |
---|
[0] | 332 | |
---|
| 333 | echo |
---|
| 334 | '<h3>'.__('Video size').'</h3>'. |
---|
[1009] | 335 | '<p><label for="video_w" class="classic">'.__('Width:').'</label> '. |
---|
[0] | 336 | form::field('video_w',3,4,400).' '. |
---|
[1009] | 337 | '<label for="video_h" class="classic">'.__('Height:').'</label> '. |
---|
[0] | 338 | form::field('video_h',3,4,300). |
---|
| 339 | '</p>'; |
---|
| 340 | |
---|
| 341 | echo '<h3>'.__('Video disposition').'</h3>'; |
---|
| 342 | |
---|
| 343 | $i_align = array( |
---|
[950] | 344 | 'none' => array(__('None'),($media_img_default_alignment == 'none' ? 1 : 0)), |
---|
| 345 | 'left' => array(__('Left'),($media_img_default_alignment == 'left' ? 1 : 0)), |
---|
| 346 | 'right' => array(__('Right'),($media_img_default_alignment == 'right' ? 1 : 0)), |
---|
| 347 | 'center' => array(__('Center'),($media_img_default_alignment == 'center' ? 1 : 0)) |
---|
[0] | 348 | ); |
---|
| 349 | |
---|
| 350 | echo '<p>'; |
---|
| 351 | foreach ($i_align as $k => $v) { |
---|
[1853] | 352 | echo '<label class="classic">'. |
---|
[0] | 353 | form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; |
---|
| 354 | } |
---|
| 355 | |
---|
| 356 | $public_player_style = unserialize($core->blog->settings->themes->flvplayer_style); |
---|
| 357 | $public_player = dcMedia::flvplayer($file->file_url,$core->blog->getQmarkURL().'pf=player_flv.swf',$public_player_style); |
---|
| 358 | echo form::hidden('public_player',html::escapeHTML($public_player)); |
---|
| 359 | echo '</p>'; |
---|
| 360 | } |
---|
| 361 | else |
---|
| 362 | { |
---|
| 363 | $media_type = 'default'; |
---|
| 364 | echo '<p>'.__('Media item will be inserted as a link.').'</p>'; |
---|
| 365 | } |
---|
[2093] | 366 | |
---|
[0] | 367 | echo |
---|
[2094] | 368 | '<p>'. |
---|
| 369 | '<a id="media-insert-ok" class="button submit" href="#">'.__('Insert').'</a> '. |
---|
| 370 | '<a id="media-insert-cancel" class="button" href="#">'.__('Cancel').'</a>'. |
---|
[0] | 371 | form::hidden(array('type'),html::escapeHTML($media_type)). |
---|
| 372 | form::hidden(array('title'),html::escapeHTML($file->media_title)). |
---|
| 373 | form::hidden(array('description'),html::escapeHTML($media_desc)). |
---|
| 374 | form::hidden(array('url'),$file->file_url). |
---|
| 375 | '</p>'; |
---|
| 376 | |
---|
[2093] | 377 | echo '</form>'; |
---|
| 378 | |
---|
| 379 | if ($media_type != 'default') { |
---|
| 380 | echo |
---|
[2094] | 381 | '<div class="border-top">'. |
---|
[2093] | 382 | '<form id="save_settings" action="'.html::escapeURL($page_url).'" method="post">'. |
---|
[2094] | 383 | '<p>'.__('Make current settings as default').' '. |
---|
| 384 | '<input class="reset" type="submit" name="save_blog_prefs" value="'.__('OK').'" />'. |
---|
[2093] | 385 | form::hidden(array('pref_src'),''). |
---|
| 386 | form::hidden(array('pref_alignment'),''). |
---|
| 387 | form::hidden(array('pref_insertion'),''). |
---|
| 388 | form::hidden(array('id'),$id). |
---|
| 389 | $core->formNonce().'</p>'. |
---|
[2094] | 390 | '</form>'.'</div>'; |
---|
[2093] | 391 | } |
---|
| 392 | |
---|
| 393 | echo '</div>'; |
---|
[0] | 394 | } |
---|
| 395 | |
---|
[1996] | 396 | if ($popup) { |
---|
| 397 | echo |
---|
| 398 | '<div class="multi-part" title="'.__('Media details').'" id="media-details-tab">'; |
---|
| 399 | } else { |
---|
| 400 | echo '<h3 class="out-of-screen-if-js">'.__('Media details').'</h3>'; |
---|
| 401 | } |
---|
[0] | 402 | echo |
---|
[1038] | 403 | '<p id="media-icon"><img src="'.$file->media_icon.'?'.time()*rand().'" alt="" /></p>'; |
---|
[0] | 404 | |
---|
| 405 | echo |
---|
[1454] | 406 | '<div id="media-details">'. |
---|
| 407 | '<div class="near-icon">'; |
---|
[0] | 408 | |
---|
| 409 | if ($file->media_image) |
---|
| 410 | { |
---|
| 411 | $thumb_size = !empty($_GET['size']) ? $_GET['size'] : 's'; |
---|
| 412 | |
---|
| 413 | if (!isset($core->media->thumb_sizes[$thumb_size]) && $thumb_size != 'o') { |
---|
| 414 | $thumb_size = 's'; |
---|
| 415 | } |
---|
| 416 | |
---|
[1454] | 417 | if (isset($file->media_thumb[$thumb_size])) { |
---|
| 418 | echo '<p><img src="'.$file->media_thumb[$thumb_size].'?'.time()*rand().'" alt="" /></p>'; |
---|
| 419 | } elseif ($thumb_size == 'o') { |
---|
| 420 | $S = getimagesize($file->file); |
---|
| 421 | $class = ($S[1] > 500) ? ' class="overheight"' : ''; |
---|
| 422 | unset($S); |
---|
| 423 | echo '<p id="media-original-image"'.$class.'><img src="'.$file->file_url.'?'.time()*rand().'" alt="" /></p>'; |
---|
| 424 | } |
---|
| 425 | |
---|
[0] | 426 | echo '<p>'.__('Available sizes:').' '; |
---|
| 427 | foreach (array_reverse($file->media_thumb) as $s => $v) |
---|
| 428 | { |
---|
| 429 | $strong_link = ($s == $thumb_size) ? '<strong>%s</strong>' : '%s'; |
---|
| 430 | printf($strong_link,'<a href="'.html::escapeURL($page_url). |
---|
[861] | 431 | '&id='.$id.'&size='.$s.'&tab=media-details-tab">'.$core->media->thumb_sizes[$s][2].'</a> | '); |
---|
[0] | 432 | } |
---|
[861] | 433 | echo '<a href="'.html::escapeURL($page_url).'&id='.$id.'&size=o&tab=media-details-tab">'.__('original').'</a>'; |
---|
[0] | 434 | echo '</p>'; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | if ($file->type == 'audio/mpeg3') |
---|
| 438 | { |
---|
| 439 | echo dcMedia::mp3player($file->file_url,'index.php?pf=player_mp3.swf'); |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | if ($file->type == 'video/x-flv' || $file->type == 'video/mp4' || $file->type == 'video/x-m4v') |
---|
| 443 | { |
---|
| 444 | echo dcMedia::flvplayer($file->file_url,'index.php?pf=player_flv.swf'); |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | echo |
---|
| 448 | '<h3>'.__('Media details').'</h3>'. |
---|
| 449 | '<ul>'. |
---|
| 450 | '<li><strong>'.__('File owner:').'</strong> '.$file->media_user.'</li>'. |
---|
| 451 | '<li><strong>'.__('File type:').'</strong> '.$file->type.'</li>'. |
---|
| 452 | '<li><strong>'.__('File size:').'</strong> '.files::size($file->size).'</li>'. |
---|
| 453 | '<li><strong>'.__('File URL:').'</strong> <a href="'.$file->file_url.'">'.$file->file_url.'</a></li>'. |
---|
| 454 | '</ul>'; |
---|
| 455 | |
---|
| 456 | if (empty($_GET['find_posts'])) |
---|
| 457 | { |
---|
| 458 | echo |
---|
[1605] | 459 | '<p><a class="button" href="'.html::escapeHTML($page_url).'&id='.$id.'&find_posts=1&tab=media-details-tab">'. |
---|
| 460 | __('Show entries containing this media').'</a></p>'; |
---|
[0] | 461 | } |
---|
| 462 | else |
---|
| 463 | { |
---|
| 464 | echo '<h3>'.__('Entries containing this media').'</h3>'; |
---|
| 465 | $params = array( |
---|
| 466 | 'post_type' => '', |
---|
| 467 | 'from' => 'LEFT OUTER JOIN '.$core->prefix.'post_media PM ON P.post_id = PM.post_id ', |
---|
| 468 | 'sql' => 'AND ('. |
---|
| 469 | 'PM.media_id = '.(integer) $id.' '. |
---|
| 470 | "OR post_content_xhtml LIKE '%".$core->con->escape($file->relname)."%' ". |
---|
| 471 | "OR post_excerpt_xhtml LIKE '%".$core->con->escape($file->relname)."%' " |
---|
| 472 | ); |
---|
| 473 | |
---|
| 474 | if ($file->media_image) |
---|
| 475 | { # We look for thumbnails too |
---|
[663] | 476 | if (preg_match('#^http(s)?://#',$core->blog->settings->system->public_url)) { |
---|
[375] | 477 | $media_root = $core->blog->settings->system->public_url; |
---|
| 478 | } else { |
---|
| 479 | $media_root = $core->blog->host.path::clean($core->blog->settings->system->public_url).'/'; |
---|
| 480 | } |
---|
[0] | 481 | foreach ($file->media_thumb as $v) { |
---|
| 482 | $v = preg_replace('/^'.preg_quote($media_root,'/').'/','',$v); |
---|
| 483 | $params['sql'] .= "OR post_content_xhtml LIKE '%".$core->con->escape($v)."%' "; |
---|
| 484 | $params['sql'] .= "OR post_excerpt_xhtml LIKE '%".$core->con->escape($v)."%' "; |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | $params['sql'] .= ') '; |
---|
| 489 | |
---|
| 490 | $rs = $core->blog->getPosts($params); |
---|
| 491 | |
---|
| 492 | if ($rs->isEmpty()) |
---|
| 493 | { |
---|
| 494 | echo '<p>'.__('No entry seems contain this media.').'</p>'; |
---|
| 495 | } |
---|
| 496 | else |
---|
| 497 | { |
---|
| 498 | echo '<ul>'; |
---|
| 499 | while ($rs->fetch()) { |
---|
[918] | 500 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
| 501 | switch ($rs->post_status) { |
---|
| 502 | case 1: |
---|
| 503 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
| 504 | break; |
---|
| 505 | case 0: |
---|
| 506 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
| 507 | break; |
---|
| 508 | case -1: |
---|
| 509 | $img_status = sprintf($img,__('scheduled'),'scheduled.png'); |
---|
| 510 | break; |
---|
| 511 | case -2: |
---|
| 512 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
| 513 | break; |
---|
| 514 | } |
---|
| 515 | echo '<li>'.$img_status.' '.'<a href="'.$core->getPostAdminURL($rs->post_type,$rs->post_id).'">'. |
---|
| 516 | $rs->post_title.'</a>'. |
---|
| 517 | ($rs->post_type != 'post' ? ' ('.html::escapeHTML($rs->post_type).')' : ''). |
---|
| 518 | ' - '.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->post_dt).'</li>'; |
---|
[0] | 519 | } |
---|
| 520 | echo '</ul>'; |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | if ($file->type == 'image/jpeg') |
---|
| 525 | { |
---|
| 526 | echo '<h3>'.__('Image details').'</h3>'; |
---|
| 527 | |
---|
[2106] | 528 | $details = ''; |
---|
| 529 | if (count($file->media_meta) > 0) |
---|
[0] | 530 | { |
---|
| 531 | foreach ($file->media_meta as $k => $v) |
---|
| 532 | { |
---|
| 533 | if ((string) $v) { |
---|
[2106] | 534 | $details .= '<li><strong>'.$k.':</strong> '.html::escapeHTML($v).'</li>'; |
---|
[0] | 535 | } |
---|
| 536 | } |
---|
[2106] | 537 | } |
---|
| 538 | if ($details) { |
---|
| 539 | echo '<ul>'.$details.'</ul>'; |
---|
| 540 | } else { |
---|
| 541 | echo '<p>'.__('No detail').'</p>'; |
---|
[0] | 542 | } |
---|
| 543 | } |
---|
| 544 | |
---|
[1454] | 545 | echo '</div>'; |
---|
| 546 | |
---|
[1499] | 547 | echo '<h3>'.__('Updates and modifications').'</h3>'; |
---|
| 548 | |
---|
[0] | 549 | if ($file->editable && $core_media_writable) |
---|
| 550 | { |
---|
| 551 | if ($file->media_type == 'image') |
---|
| 552 | { |
---|
| 553 | echo |
---|
[1499] | 554 | '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post">'. |
---|
| 555 | '<h4>'.__('Update thumbnails').'</h4>'. |
---|
[0] | 556 | '<p>'.__('This will create or update thumbnails for this image.').'</p>'. |
---|
[557] | 557 | '<p><input type="submit" name="thumbs" value="'.__('Update thumbnails').'" />'. |
---|
[0] | 558 | form::hidden(array('id'),$id). |
---|
| 559 | $core->formNonce().'</p>'. |
---|
[1499] | 560 | '</form>'; |
---|
[0] | 561 | } |
---|
| 562 | |
---|
| 563 | if ($file->type == 'application/zip') |
---|
| 564 | { |
---|
| 565 | $inflate_combo = array( |
---|
| 566 | __('Extract in a new directory') => 'new', |
---|
| 567 | __('Extract in current directory') => 'current' |
---|
| 568 | ); |
---|
| 569 | |
---|
| 570 | echo |
---|
[1499] | 571 | '<form class="clear fieldset" id="file-unzip" action="'.html::escapeURL($page_url).'" method="post">'. |
---|
| 572 | '<h4>'.__('Extract archive').'</h4>'. |
---|
[0] | 573 | '<ul>'. |
---|
| 574 | '<li><strong>'.__('Extract in a new directory').'</strong> : '. |
---|
| 575 | __('This will extract archive in a new directory that should not exist yet.').'</li>'. |
---|
| 576 | '<li><strong>'.__('Extract in current directory').'</strong> : '. |
---|
| 577 | __('This will extract archive in current directory and will overwrite existing files or directory.').'</li>'. |
---|
| 578 | '</ul>'. |
---|
[1399] | 579 | '<p><label for="inflate_mode" class="classic">'.__('Extract mode:').'</label> '. |
---|
| 580 | form::combo('inflate_mode',$inflate_combo,'new'). |
---|
[557] | 581 | '<input type="submit" name="unzip" value="'.__('Extract').'" />'. |
---|
[0] | 582 | form::hidden(array('id'),$id). |
---|
| 583 | $core->formNonce().'</p>'. |
---|
[1499] | 584 | '</form>'; |
---|
[0] | 585 | } |
---|
| 586 | |
---|
| 587 | echo |
---|
[1499] | 588 | '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post">'. |
---|
| 589 | '<h4>'.__('Change media properties').'</h4>'. |
---|
[1399] | 590 | '<p><label for="media_file">'.__('File name:').'</label>'. |
---|
| 591 | form::field('media_file',30,255,html::escapeHTML($file->basename)).'</p>'. |
---|
| 592 | '<p><label for="media_title">'.__('File title:').'</label>'. |
---|
| 593 | form::field('media_title',30,255,html::escapeHTML($file->media_title)).'</p>'. |
---|
| 594 | '<p><label for="media_dt">'.__('File date:').'</label>'. |
---|
| 595 | form::field('media_dt',16,16,html::escapeHTML($file->media_dtstr)).'</p>'. |
---|
[68] | 596 | '<p><label for="media_private" class="classic">'.form::checkbox('media_private',1,$file->media_priv).' '. |
---|
[0] | 597 | __('Private').'</label></p>'. |
---|
[1399] | 598 | '<p><label for="media_path">'.__('New directory:').'</label>'. |
---|
| 599 | form::combo('media_path',$dirs_combo,dirname($file->relname)).'</p>'. |
---|
[217] | 600 | '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'. |
---|
[0] | 601 | form::hidden(array('id'),$id). |
---|
| 602 | $core->formNonce().'</p>'. |
---|
[1499] | 603 | '</form>'; |
---|
[0] | 604 | |
---|
| 605 | echo |
---|
[1499] | 606 | '<form class="clear fieldset" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data">'. |
---|
| 607 | '<h4>'.__('Change file').'</h4>'. |
---|
[0] | 608 | '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE).'</div>'. |
---|
[68] | 609 | '<p><label for="upfile">'.__('Choose a file:'). |
---|
[0] | 610 | ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).') '. |
---|
[68] | 611 | '<input type="file" id="upfile" name="upfile" size="35" />'. |
---|
[0] | 612 | '</label></p>'. |
---|
[557] | 613 | '<p><input type="submit" value="'.__('Send').'" />'. |
---|
[0] | 614 | form::hidden(array('id'),$id). |
---|
| 615 | $core->formNonce().'</p>'. |
---|
[1499] | 616 | '</form>'; |
---|
[0] | 617 | |
---|
[947] | 618 | if ($file->del) { |
---|
| 619 | echo |
---|
| 620 | '<form id="delete-form" method="post" action="'.html::escapeURL($media_page_url). |
---|
| 621 | '&d='.rawurlencode(dirname($file->relname)). |
---|
| 622 | '&remove='.rawurlencode($file->basename).'">'. |
---|
| 623 | '<p><input name="delete" type="submit" class="delete" value="'.__('Delete this media').'" />'. |
---|
| 624 | form::hidden('remove',rawurlencode($file->basename)). |
---|
| 625 | form::hidden('rmyes',1). |
---|
| 626 | $core->formNonce().'</p>'. |
---|
| 627 | '</form>'; |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | |
---|
[0] | 631 | # --BEHAVIOR-- adminMediaItemForm |
---|
| 632 | $core->callBehavior('adminMediaItemForm',$file); |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | echo |
---|
| 636 | '</div>'; |
---|
[1996] | 637 | if ($popup) { |
---|
| 638 | echo |
---|
| 639 | '</div>'; |
---|
| 640 | } |
---|
[0] | 641 | |
---|
| 642 | call_user_func($close_f); |
---|
| 643 | ?> |
---|