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