| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2010 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 | $post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null; | 
|---|
| 18 | if ($post_id) { | 
|---|
| 19 |      $post = $core->blog->getPosts(array('post_id'=>$post_id)); | 
|---|
| 20 |      if ($post->isEmpty()) { | 
|---|
| 21 |           $post_id = null; | 
|---|
| 22 |      } | 
|---|
| 23 |      $post_title = $post->post_title; | 
|---|
| 24 |      unset($post); | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | $file = null; | 
|---|
| 28 | $popup = (integer) !empty($_GET['popup']); | 
|---|
| 29 | $page_url = 'media_item.php?popup='.$popup.'&post_id='.$post_id; | 
|---|
| 30 | $media_page_url = 'media.php?popup='.$popup.'&post_id='.$post_id; | 
|---|
| 31 |  | 
|---|
| 32 | $id = !empty($_REQUEST['id']) ? (integer) $_REQUEST['id'] : ''; | 
|---|
| 33 |  | 
|---|
| 34 | if ($popup) { | 
|---|
| 35 |      $open_f = array('dcPage','openPopup'); | 
|---|
| 36 |      $close_f = array('dcPage','closePopup'); | 
|---|
| 37 | } else { | 
|---|
| 38 |      $open_f = array('dcPage','open'); | 
|---|
| 39 |      $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | $core_media_writable = false; | 
|---|
| 43 | try | 
|---|
| 44 | { | 
|---|
| 45 |      $core->media = new dcMedia($core); | 
|---|
| 46 |       | 
|---|
| 47 |      if ($id) { | 
|---|
| 48 |           $file = $core->media->getFile($id); | 
|---|
| 49 |      } | 
|---|
| 50 |       | 
|---|
| 51 |      if ($file === null) { | 
|---|
| 52 |           throw new Exception(__('Not a valid file')); | 
|---|
| 53 |      } | 
|---|
| 54 |       | 
|---|
| 55 |      $core->media->chdir(dirname($file->relname)); | 
|---|
| 56 |      $core_media_writable = $core->media->writable(); | 
|---|
| 57 |       | 
|---|
| 58 |      # Prepare directories combo box | 
|---|
| 59 |      $dirs_combo = array(); | 
|---|
| 60 |      foreach ($core->media->getRootDirs() as $v) { | 
|---|
| 61 |           if ($v->w) { | 
|---|
| 62 |                $dirs_combo['/'.$v->relname] = $v->relname; | 
|---|
| 63 |           } | 
|---|
| 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'); | 
|---|
| 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'); | 
|---|
| 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) | 
|---|
| 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 |                $res[] = dt::str($m[1],$file->media_dt); | 
|---|
| 148 |           } elseif (preg_match('/^DateTimeOriginal\((.+?)\)$/u',$v,$m) && $file->media_meta->DateTimeOriginal) { | 
|---|
| 149 |                $res[] = dt::dt2str($m[1],(string) $file->media_meta->DateTimeOriginal); | 
|---|
| 150 |           } elseif (preg_match('/^separator\((.*?)\)$/u',$v,$m)) { | 
|---|
| 151 |                $sep = $m[1]; | 
|---|
| 152 |           } | 
|---|
| 153 |      } | 
|---|
| 154 |      return implode($sep,$res); | 
|---|
| 155 | } | 
|---|
| 156 |  | 
|---|
| 157 | /* DISPLAY Main page | 
|---|
| 158 | -------------------------------------------------------- */ | 
|---|
| 159 | $starting_scripts = dcPage::jsLoad('js/_media_item.js'); | 
|---|
| 160 | if ($popup) { | 
|---|
| 161 |      $starting_scripts .= | 
|---|
| 162 |      dcPage::jsLoad('js/tiny_mce/tiny_mce_popup.js'). | 
|---|
| 163 |      dcPage::jsLoad('js/tiny_mce/plugins/dcControls/js/popup_media.js'); | 
|---|
| 164 | } | 
|---|
| 165 | call_user_func($open_f,__('Media manager'), | 
|---|
| 166 |      $starting_scripts. | 
|---|
| 167 |      dcPage::jsDatePicker(). | 
|---|
| 168 |      dcPage::jsPageTabs() | 
|---|
| 169 | ); | 
|---|
| 170 |  | 
|---|
| 171 | if ($file === null) { | 
|---|
| 172 |      call_user_func($close_f); | 
|---|
| 173 |      exit; | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | if (!empty($_GET['fupd']) || !empty($_GET['fupl'])) { | 
|---|
| 177 |      echo '<p class="message">'.__('File has been successfully updated.').'</p>'; | 
|---|
| 178 | } | 
|---|
| 179 | if (!empty($_GET['thumbupd'])) { | 
|---|
| 180 |      echo '<p class="message">'.__('Thumbnails have been successfully updated.').'</p>'; | 
|---|
| 181 | } | 
|---|
| 182 |  | 
|---|
| 183 | echo '<h2><a href="'.html::escapeURL($media_page_url).'">'.__('Media manager').'</a>'. | 
|---|
| 184 | ' / '.$core->media->breadCrumb(html::escapeURL($media_page_url).'&d=%s'). | 
|---|
| 185 | $file->basename.'</h2>'; | 
|---|
| 186 |  | 
|---|
| 187 | # Insertion popup | 
|---|
| 188 | if ($popup) | 
|---|
| 189 | { | 
|---|
| 190 |      $media_desc = $file->media_title; | 
|---|
| 191 |       | 
|---|
| 192 |      echo | 
|---|
| 193 |      '<div id="media-insert" class="multi-part" title="'.__('Insert media item').'">'. | 
|---|
| 194 |      '<form id="media-insert-form" action="" method="get">'; | 
|---|
| 195 |       | 
|---|
| 196 |      if ($file->media_type == 'image') | 
|---|
| 197 |      { | 
|---|
| 198 |           $media_type = 'image'; | 
|---|
| 199 |           $media_desc = dcGetImageTitle($file,$core->blog->settings->system->media_img_title_pattern); | 
|---|
| 200 |           if ($media_desc == $file->basename) { | 
|---|
| 201 |                $media_desc = ''; | 
|---|
| 202 |           } | 
|---|
| 203 |            | 
|---|
| 204 |           echo | 
|---|
| 205 |           '<h3>'.__('Image size:').'</h3> '; | 
|---|
| 206 |            | 
|---|
| 207 |           $s_checked = false; | 
|---|
| 208 |           echo '<p>'; | 
|---|
| 209 |           foreach (array_reverse($file->media_thumb) as $s => $v) { | 
|---|
| 210 |                $s_checked = ($s == 'm'); | 
|---|
| 211 |                echo '<label class="classic">'. | 
|---|
| 212 |                form::radio(array('src'),html::escapeHTML($v),$s_checked).' '. | 
|---|
| 213 |                $core->media->thumb_sizes[$s][2].'</label><br /> '; | 
|---|
| 214 |           } | 
|---|
| 215 |           $s_checked = (!isset($file->media_thumb['m'])); | 
|---|
| 216 |           echo '<label class="classic">'. | 
|---|
| 217 |           form::radio(array('src'),$file->file_url,$s_checked).' '.__('original').'</label><br /> '; | 
|---|
| 218 |           echo '</p>'; | 
|---|
| 219 |            | 
|---|
| 220 |            | 
|---|
| 221 |           echo '<h3>'.__('Image alignment').'</h3>'; | 
|---|
| 222 |           $i_align = array( | 
|---|
| 223 |                'none' => array(__('None'),1), | 
|---|
| 224 |                'left' => array(__('Left'),0), | 
|---|
| 225 |                'right' => array(__('Right'),0), | 
|---|
| 226 |                'center' => array(__('Center'),0) | 
|---|
| 227 |           ); | 
|---|
| 228 |            | 
|---|
| 229 |           echo '<p>'; | 
|---|
| 230 |           foreach ($i_align as $k => $v) { | 
|---|
| 231 |                echo '<label class="classic">'. | 
|---|
| 232 |                form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; | 
|---|
| 233 |           } | 
|---|
| 234 |           echo '</p>'; | 
|---|
| 235 |            | 
|---|
| 236 |           echo | 
|---|
| 237 |           '<h3>'.__('Image insertion').'</h3>'. | 
|---|
| 238 |           '<p>'. | 
|---|
| 239 |           '<label for="insert1" class="classic">'.form::radio(array('insertion','insert1'),'simple',true). | 
|---|
| 240 |           __('As a single image').'</label><br />'. | 
|---|
| 241 |           '<label for="insert2" class="classic">'.form::radio(array('insertion','insert2'),'link',false). | 
|---|
| 242 |           __('As a link to original image').'</label>'. | 
|---|
| 243 |           '</p>'; | 
|---|
| 244 |      } | 
|---|
| 245 |      elseif ($file->type == 'audio/mpeg3') | 
|---|
| 246 |      { | 
|---|
| 247 |           $media_type = 'mp3'; | 
|---|
| 248 |            | 
|---|
| 249 |           echo '<h3>'.__('MP3 disposition').'</h3>'. | 
|---|
| 250 |           '<p class="message">'.__("Please note that you cannot insert mp3 files with visual editor.").'</p>'; | 
|---|
| 251 |            | 
|---|
| 252 |           $i_align = array( | 
|---|
| 253 |                'none' => array(__('None'),0), | 
|---|
| 254 |                'left' => array(__('Left'),0), | 
|---|
| 255 |                'right' => array(__('Right'),0), | 
|---|
| 256 |                'center' => array(__('Center'),1) | 
|---|
| 257 |           ); | 
|---|
| 258 |            | 
|---|
| 259 |           echo '<p>'; | 
|---|
| 260 |           foreach ($i_align as $k => $v) { | 
|---|
| 261 |                echo '<label for="alignment" class="classic">'. | 
|---|
| 262 |                form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; | 
|---|
| 263 |           } | 
|---|
| 264 |            | 
|---|
| 265 |           $public_player_style = unserialize($core->blog->settings->themes->mp3player_style); | 
|---|
| 266 |           $public_player = dcMedia::mp3player($file->file_url,$core->blog->getQmarkURL().'pf=player_mp3.swf',$public_player_style); | 
|---|
| 267 |           echo form::hidden('public_player',html::escapeHTML($public_player)); | 
|---|
| 268 |           echo '</p>'; | 
|---|
| 269 |      } | 
|---|
| 270 |      elseif ($file->type == 'video/x-flv' || $file->type == 'video/mp4' || $file->type == 'video/x-m4v') | 
|---|
| 271 |      { | 
|---|
| 272 |           $media_type = 'flv'; | 
|---|
| 273 |            | 
|---|
| 274 |           echo | 
|---|
| 275 |           '<p class="message">'.__("Please note that you cannot insert video files with visual editor.").'</p>'; | 
|---|
| 276 |            | 
|---|
| 277 |           echo | 
|---|
| 278 |           '<h3>'.__('Video size').'</h3>'. | 
|---|
| 279 |           '<p><label for="video_w" class="classic">'.__('Width:').' '. | 
|---|
| 280 |           form::field('video_w',3,4,400).'  '. | 
|---|
| 281 |           '<label for="video_h" class="classic">'.__('Height:').' '. | 
|---|
| 282 |           form::field('video_h',3,4,300). | 
|---|
| 283 |           '</p>'; | 
|---|
| 284 |            | 
|---|
| 285 |           echo '<h3>'.__('Video disposition').'</h3>'; | 
|---|
| 286 |            | 
|---|
| 287 |           $i_align = array( | 
|---|
| 288 |                'none' => array(__('None'),0), | 
|---|
| 289 |                'left' => array(__('Left'),0), | 
|---|
| 290 |                'right' => array(__('Right'),0), | 
|---|
| 291 |                'center' => array(__('Center'),1) | 
|---|
| 292 |           ); | 
|---|
| 293 |            | 
|---|
| 294 |           echo '<p>'; | 
|---|
| 295 |           foreach ($i_align as $k => $v) { | 
|---|
| 296 |                echo '<label for="alignment" class="classic">'. | 
|---|
| 297 |                form::radio(array('alignment'),$k,$v[1]).' '.$v[0].'</label><br /> '; | 
|---|
| 298 |           } | 
|---|
| 299 |            | 
|---|
| 300 |           $public_player_style = unserialize($core->blog->settings->themes->flvplayer_style); | 
|---|
| 301 |           $public_player = dcMedia::flvplayer($file->file_url,$core->blog->getQmarkURL().'pf=player_flv.swf',$public_player_style); | 
|---|
| 302 |           echo form::hidden('public_player',html::escapeHTML($public_player)); | 
|---|
| 303 |           echo '</p>'; | 
|---|
| 304 |      } | 
|---|
| 305 |      else | 
|---|
| 306 |      { | 
|---|
| 307 |           $media_type = 'default'; | 
|---|
| 308 |           echo '<p>'.__('Media item will be inserted as a link.').'</p>'; | 
|---|
| 309 |      } | 
|---|
| 310 |       | 
|---|
| 311 |      echo | 
|---|
| 312 |      '<p><a id="media-insert-cancel" class="button" href="#">'.__('Cancel').'</a> - '. | 
|---|
| 313 |      '<strong><a id="media-insert-ok" class="button" href="#">'.__('Insert').'</a></strong>'. | 
|---|
| 314 |      form::hidden(array('type'),html::escapeHTML($media_type)). | 
|---|
| 315 |      form::hidden(array('title'),html::escapeHTML($file->media_title)). | 
|---|
| 316 |      form::hidden(array('description'),html::escapeHTML($media_desc)). | 
|---|
| 317 |      form::hidden(array('url'),$file->file_url). | 
|---|
| 318 |      '</p>'; | 
|---|
| 319 |       | 
|---|
| 320 |      echo '</form></div>'; | 
|---|
| 321 | } | 
|---|
| 322 |  | 
|---|
| 323 | echo | 
|---|
| 324 | '<div class="multi-part" title="'.__('Media details').'" id="media-details-tab">'. | 
|---|
| 325 | '<p id="media-icon"><img src="'.$file->media_icon.'" alt="" /></p>'; | 
|---|
| 326 |  | 
|---|
| 327 | echo | 
|---|
| 328 | '<div id="media-details">'; | 
|---|
| 329 |  | 
|---|
| 330 | if ($file->media_image) | 
|---|
| 331 | { | 
|---|
| 332 |      $thumb_size = !empty($_GET['size']) ? $_GET['size'] : 's'; | 
|---|
| 333 |       | 
|---|
| 334 |      if (!isset($core->media->thumb_sizes[$thumb_size]) && $thumb_size != 'o') { | 
|---|
| 335 |           $thumb_size = 's'; | 
|---|
| 336 |      } | 
|---|
| 337 |       | 
|---|
| 338 |      echo '<p>'.__('Available sizes:').' '; | 
|---|
| 339 |      foreach (array_reverse($file->media_thumb) as $s => $v) | 
|---|
| 340 |      { | 
|---|
| 341 |           $strong_link = ($s == $thumb_size) ? '<strong>%s</strong>' : '%s'; | 
|---|
| 342 |           printf($strong_link,'<a href="'.html::escapeURL($page_url). | 
|---|
| 343 |           '&id='.$id.'&size='.$s.'">'.$core->media->thumb_sizes[$s][2].'</a> | '); | 
|---|
| 344 |      } | 
|---|
| 345 |      echo '<a href="'.html::escapeURL($page_url).'&id='.$id.'&size=o">'.__('original').'</a>'; | 
|---|
| 346 |      echo '</p>'; | 
|---|
| 347 |       | 
|---|
| 348 |      if (isset($file->media_thumb[$thumb_size])) { | 
|---|
| 349 |           echo '<p><img src="'.$file->media_thumb[$thumb_size].'" alt="" /></p>'; | 
|---|
| 350 |      } elseif ($thumb_size == 'o') { | 
|---|
| 351 |           $S = getimagesize($file->file); | 
|---|
| 352 |           $class = ($S[1] > 500) ? ' class="overheight"' : ''; | 
|---|
| 353 |           unset($S); | 
|---|
| 354 |           echo '<p id="media-original-image"'.$class.'><img src="'.$file->file_url.'" alt="" /></p>'; | 
|---|
| 355 |      } | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | if ($file->type == 'audio/mpeg3') | 
|---|
| 359 | { | 
|---|
| 360 |      echo dcMedia::mp3player($file->file_url,'index.php?pf=player_mp3.swf'); | 
|---|
| 361 | } | 
|---|
| 362 |  | 
|---|
| 363 | if ($file->type == 'video/x-flv' || $file->type == 'video/mp4' || $file->type == 'video/x-m4v') | 
|---|
| 364 | { | 
|---|
| 365 |      echo dcMedia::flvplayer($file->file_url,'index.php?pf=player_flv.swf'); | 
|---|
| 366 | } | 
|---|
| 367 |  | 
|---|
| 368 | echo | 
|---|
| 369 | '<h3>'.__('Media details').'</h3>'. | 
|---|
| 370 | '<ul>'. | 
|---|
| 371 |      '<li><strong>'.__('File owner:').'</strong> '.$file->media_user.'</li>'. | 
|---|
| 372 |      '<li><strong>'.__('File type:').'</strong> '.$file->type.'</li>'. | 
|---|
| 373 |      '<li><strong>'.__('File size:').'</strong> '.files::size($file->size).'</li>'. | 
|---|
| 374 |      '<li><strong>'.__('File URL:').'</strong> <a href="'.$file->file_url.'">'.$file->file_url.'</a></li>'. | 
|---|
| 375 | '</ul>'; | 
|---|
| 376 |  | 
|---|
| 377 | if (empty($_GET['find_posts'])) | 
|---|
| 378 | { | 
|---|
| 379 |      echo | 
|---|
| 380 |      '<p><strong><a href="'.html::escapeHTML($page_url).'&id='.$id.'&find_posts=1">'. | 
|---|
| 381 |      __('Show entries containing this media').'</a></strong></p>'; | 
|---|
| 382 | } | 
|---|
| 383 | else | 
|---|
| 384 | { | 
|---|
| 385 |      echo '<h3>'.__('Entries containing this media').'</h3>'; | 
|---|
| 386 |      $params = array( | 
|---|
| 387 |           'post_type' => '', | 
|---|
| 388 |           'from' => 'LEFT OUTER JOIN '.$core->prefix.'post_media PM ON P.post_id = PM.post_id ', | 
|---|
| 389 |           'sql' => 'AND ('. | 
|---|
| 390 |                'PM.media_id = '.(integer) $id.' '. | 
|---|
| 391 |                "OR post_content_xhtml LIKE '%".$core->con->escape($file->relname)."%' ". | 
|---|
| 392 |                "OR post_excerpt_xhtml LIKE '%".$core->con->escape($file->relname)."%' " | 
|---|
| 393 |      ); | 
|---|
| 394 |       | 
|---|
| 395 |      if ($file->media_image) | 
|---|
| 396 |      { # We look for thumbnails too | 
|---|
| 397 |           $media_root = $core->blog->host.path::clean($core->blog->settings->system->public_url).'/'; | 
|---|
| 398 |           foreach ($file->media_thumb as $v) { | 
|---|
| 399 |                $v = preg_replace('/^'.preg_quote($media_root,'/').'/','',$v); | 
|---|
| 400 |                $params['sql'] .= "OR post_content_xhtml LIKE '%".$core->con->escape($v)."%' "; | 
|---|
| 401 |                $params['sql'] .= "OR post_excerpt_xhtml LIKE '%".$core->con->escape($v)."%' "; | 
|---|
| 402 |           } | 
|---|
| 403 |      } | 
|---|
| 404 |       | 
|---|
| 405 |      $params['sql'] .= ') '; | 
|---|
| 406 |       | 
|---|
| 407 |      $rs = $core->blog->getPosts($params); | 
|---|
| 408 |       | 
|---|
| 409 |      if ($rs->isEmpty()) | 
|---|
| 410 |      { | 
|---|
| 411 |           echo '<p>'.__('No entry seems contain this media.').'</p>'; | 
|---|
| 412 |      } | 
|---|
| 413 |      else | 
|---|
| 414 |      { | 
|---|
| 415 |           echo '<ul>'; | 
|---|
| 416 |           while ($rs->fetch()) { | 
|---|
| 417 |                echo '<li><a href="'.$core->getPostAdminURL($rs->post_type,$rs->post_id).'">'. | 
|---|
| 418 |                $rs->post_title.'</a>'. | 
|---|
| 419 |                ($rs->post_type != 'post' ? ' ('.html::escapeHTML($rs->post_type).')' : ''). | 
|---|
| 420 |                ' - '.dt::dt2str(__('%Y-%m-%d %H:%M'),$rs->post_dt).'</li>'; | 
|---|
| 421 |           } | 
|---|
| 422 |           echo '</ul>'; | 
|---|
| 423 |      } | 
|---|
| 424 | } | 
|---|
| 425 |  | 
|---|
| 426 | if ($file->type == 'image/jpeg') | 
|---|
| 427 | { | 
|---|
| 428 |      echo '<h3>'.__('Image details').'</h3>'; | 
|---|
| 429 |       | 
|---|
| 430 |      if (count($file->media_meta) == 0) | 
|---|
| 431 |      { | 
|---|
| 432 |           echo '<p>'.__('No detail').'</p>'; | 
|---|
| 433 |      } | 
|---|
| 434 |      else | 
|---|
| 435 |      { | 
|---|
| 436 |           echo '<ul>'; | 
|---|
| 437 |           foreach ($file->media_meta as $k => $v) | 
|---|
| 438 |           { | 
|---|
| 439 |                if ((string) $v) { | 
|---|
| 440 |                     echo '<li><strong>'.$k.':</strong> '.html::escapeHTML($v).'</li>'; | 
|---|
| 441 |                } | 
|---|
| 442 |           } | 
|---|
| 443 |           echo '</ul>'; | 
|---|
| 444 |      } | 
|---|
| 445 | } | 
|---|
| 446 |  | 
|---|
| 447 | if ($file->editable && $core_media_writable) | 
|---|
| 448 | { | 
|---|
| 449 |      if ($file->media_type == 'image') | 
|---|
| 450 |      { | 
|---|
| 451 |           echo | 
|---|
| 452 |           '<form class="clear" action="'.html::escapeURL($page_url).'" method="post">'. | 
|---|
| 453 |           '<fieldset><legend>'.__('Update thumbnails').'</legend>'. | 
|---|
| 454 |           '<p>'.__('This will create or update thumbnails for this image.').'</p>'. | 
|---|
| 455 |           '<p><input type="submit" name="thumbs" value="'.__('update thumbnails').'" />'. | 
|---|
| 456 |           form::hidden(array('id'),$id). | 
|---|
| 457 |           $core->formNonce().'</p>'. | 
|---|
| 458 |           '</fieldset></form>'; | 
|---|
| 459 |      } | 
|---|
| 460 |       | 
|---|
| 461 |      if ($file->type == 'application/zip') | 
|---|
| 462 |      { | 
|---|
| 463 |           $inflate_combo = array( | 
|---|
| 464 |                __('Extract in a new directory') => 'new', | 
|---|
| 465 |                __('Extract in current directory') => 'current' | 
|---|
| 466 |           ); | 
|---|
| 467 |            | 
|---|
| 468 |           echo | 
|---|
| 469 |           '<form class="clear" id="file-unzip" action="'.html::escapeURL($page_url).'" method="post">'. | 
|---|
| 470 |           '<fieldset><legend>'.__('Extract archive').'</legend>'. | 
|---|
| 471 |           '<ul>'. | 
|---|
| 472 |           '<li><strong>'.__('Extract in a new directory').'</strong> : '. | 
|---|
| 473 |           __('This will extract archive in a new directory that should not exist yet.').'</li>'. | 
|---|
| 474 |           '<li><strong>'.__('Extract in current directory').'</strong> : '. | 
|---|
| 475 |           __('This will extract archive in current directory and will overwrite existing files or directory.').'</li>'. | 
|---|
| 476 |           '</ul>'. | 
|---|
| 477 |           '<p><label for="inflate_mode" class="classic">'.__('Extract mode:').' '. | 
|---|
| 478 |           form::combo('inflate_mode',$inflate_combo,'new').'</label> '. | 
|---|
| 479 |           '<input type="submit" name="unzip" value="'.__('extract').'" />'. | 
|---|
| 480 |           form::hidden(array('id'),$id). | 
|---|
| 481 |           $core->formNonce().'</p>'. | 
|---|
| 482 |           '</fieldset></form>'; | 
|---|
| 483 |      } | 
|---|
| 484 |       | 
|---|
| 485 |      echo | 
|---|
| 486 |      '<form class="clear" action="'.html::escapeURL($page_url).'" method="post">'. | 
|---|
| 487 |      '<fieldset><legend>'.__('Change media properties').'</legend>'. | 
|---|
| 488 |      '<p><label for="media_file">'.__('File name:'). | 
|---|
| 489 |      form::field('media_file',30,255,html::escapeHTML($file->basename)).'</label></p>'. | 
|---|
| 490 |      '<p><label for="media_title">'.__('File title:'). | 
|---|
| 491 |      form::field('media_title',30,255,html::escapeHTML($file->media_title)).'</label></p>'. | 
|---|
| 492 |      '<p><label for="media_dt">'.__('File date:'). | 
|---|
| 493 |      form::field('media_dt',16,16,html::escapeHTML($file->media_dtstr)).'</label></p>'. | 
|---|
| 494 |      '<p><label for="media_private" class="classic">'.form::checkbox('media_private',1,$file->media_priv).' '. | 
|---|
| 495 |      __('Private').'</label></p>'. | 
|---|
| 496 |      '<p><label for="media_path">'.__('New directory:'). | 
|---|
| 497 |      form::combo('media_path',$dirs_combo,dirname($file->relname)).'</label></p>'. | 
|---|
| 498 |      '<p><input type="submit" accesskey="s" value="'.__('Save').'" />'. | 
|---|
| 499 |      form::hidden(array('id'),$id). | 
|---|
| 500 |      $core->formNonce().'</p>'. | 
|---|
| 501 |      '</fieldset></form>'; | 
|---|
| 502 |       | 
|---|
| 503 |      echo | 
|---|
| 504 |      '<form class="clear" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data">'. | 
|---|
| 505 |      '<fieldset><legend>'.__('Change file').'</legend>'. | 
|---|
| 506 |      '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE).'</div>'. | 
|---|
| 507 |      '<p><label for="upfile">'.__('Choose a file:'). | 
|---|
| 508 |      ' ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).') '. | 
|---|
| 509 |      '<input type="file" id="upfile" name="upfile" size="35" />'. | 
|---|
| 510 |      '</label></p>'. | 
|---|
| 511 |      '<p><input type="submit" value="'.__('send').'" />'. | 
|---|
| 512 |      form::hidden(array('id'),$id). | 
|---|
| 513 |      $core->formNonce().'</p>'. | 
|---|
| 514 |      '</fieldset></form>'; | 
|---|
| 515 |  | 
|---|
| 516 |      # --BEHAVIOR-- adminMediaItemForm | 
|---|
| 517 |      $core->callBehavior('adminMediaItemForm',$file); | 
|---|
| 518 | } | 
|---|
| 519 |  | 
|---|
| 520 | echo | 
|---|
| 521 | '</div>'. | 
|---|
| 522 | '</div>'; | 
|---|
| 523 |  | 
|---|
| 524 | call_user_func($close_f); | 
|---|
| 525 | ?> | 
|---|