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