diff options
Diffstat (limited to 'inc/media.php')
-rw-r--r-- | inc/media.php | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/inc/media.php b/inc/media.php index 4e014877b..66984e957 100644 --- a/inc/media.php +++ b/inc/media.php @@ -108,7 +108,7 @@ function media_metaform($id,$auth){ $src = mediaFN($id); // output - $form = new Doku_Form(array('action' => media_managerURL(array('tab_details' => 'view')), + $form = new Doku_Form(array('action' => media_managerURL(array('tab_details' => 'view'), '&'), 'class' => 'meta')); $form->addHidden('img', $id); $form->addHidden('mediado', 'save'); @@ -175,10 +175,10 @@ define('DOKU_MEDIA_EMPTY_NS', 8); * * @author Andreas Gohr <andi@splitbrain.org> * @return int One of: 0, - DOKU_MEDIA_DELETED, - DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS, - DOKU_MEDIA_NOT_AUTH, - DOKU_MEDIA_INUSE + * DOKU_MEDIA_DELETED, + * DOKU_MEDIA_DELETED | DOKU_MEDIA_EMPTY_NS, + * DOKU_MEDIA_NOT_AUTH, + * DOKU_MEDIA_INUSE */ function media_delete($id,$auth){ global $lang; @@ -230,16 +230,18 @@ function media_upload_xhr($ns,$auth){ $id = $_GET['qqfile']; list($ext,$mime,$dl) = mimetype($id); $input = fopen("php://input", "r"); - $temp = tmpfile(); - $realSize = stream_copy_to_stream($input, $temp); - fclose($input); - if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; if (!($tmp = io_mktmpdir())) return false; $path = $tmp.'/'.md5($id); $target = fopen($path, "w"); - fseek($temp, 0, SEEK_SET); - stream_copy_to_stream($temp, $target); + $realSize = stream_copy_to_stream($input, $target); fclose($target); + fclose($input); + if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]){ + unlink($target); + unlink($path); + return false; + } + $res = media_save( array('name' => $path, 'mime' => $mime, @@ -332,7 +334,7 @@ function media_save($file, $id, $ow, $auth, $move) { global $lang, $conf; // get filename - $id = cleanID($id,false,true); + $id = cleanID($id); $fn = mediaFN($id); // get filetype regexp @@ -751,7 +753,7 @@ function media_tab_search($ns,$auth=null) { echo '<div class="search">'.NL; media_searchform($ns, $query, true); - if ($do == 'searchlist') { + if ($do == 'searchlist' || $query) { media_searchlist($query,$ns,$auth,true,_media_get_sort_type()); } echo '</div>'.NL; @@ -824,6 +826,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) { $size = media_image_preview_size($image, $rev, $meta); if ($size) { + global $lang; echo '<div class="image">'; $more = array(); @@ -837,7 +840,10 @@ function media_preview($image, $auth, $rev=false, $meta=false) { $more['w'] = $size[0]; $more['h'] = $size[1]; $src = ml($image, $more); + + echo '<a href="'.$src.'" target="_blank" title="'.$lang['mediaview'].'">'; echo '<img src="'.$src.'" alt="" style="max-width: '.$size[0].'px;" />'; + echo '</a>'; echo '</div>'.NL; } @@ -1104,6 +1110,7 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ list($l_head, $r_head) = html_diff_head($l_rev, $r_rev, $image, true); ?> + <div class="table"> <table> <tr> <th><?php echo $l_head; ?></th> @@ -1171,6 +1178,7 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ echo '</tr>'.NL; echo '</table>'.NL; + echo '</div>'.NL; if ($is_img && !$fromajax) echo '</div>'; } @@ -1344,7 +1352,7 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ $info .= filesize_h($item['size']); // output - echo '<div class="'.$zebra.'"'.$jump.'>'.NL; + echo '<div class="'.$zebra.'"'.$jump.' title="'.hsc($item['id']).'">'.NL; if (!$display_namespace) { echo '<a name="h_:'.$item['id'].'" class="'.$class.'">'.hsc($file).'</a> '; } else { @@ -1358,7 +1366,7 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ 'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /></a>'; // mediamanager button - $link = wl('',array('do'=>'media','image'=>$item['id'])); + $link = wl('',array('do'=>'media','image'=>$item['id'],'ns'=>getNS($item['id']))); echo ' <a href="'.$link.'" target="_blank"><img src="'.DOKU_BASE.'lib/images/mediamanager.png" '. 'alt="'.$lang['btn_media'].'" title="'.$lang['btn_media'].'" class="btn" /></a>'; @@ -1405,7 +1413,7 @@ function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false $file = utf8_decodeFN($item['file']); // output - echo '<li><dl>'.NL; + echo '<li><dl title="'.hsc($item['id']).'">'.NL; echo '<dt>'; if($item['isimg']) { @@ -1668,7 +1676,7 @@ function media_nstree_item($item){ $ret = ''; if (!($_REQUEST['do'] == 'media')) $ret .= '<a href="'.DOKU_BASE.'lib/exe/mediamanager.php?ns='.idfilter($item['id']).'" class="idx_dir">'; - else $ret .= '<a href="'.media_managerURL(array('ns' => idfilter($item['id']), 'tab_files' => 'files')) + else $ret .= '<a href="'.media_managerURL(array('ns' => idfilter($item['id'], false), 'tab_files' => 'files')) .'" class="idx_dir">'; $ret .= $item['label']; $ret .= '</a>'; @@ -1772,7 +1780,7 @@ function media_crop_image($file, $ext, $w, $h=0){ $local = getCacheName($file,'.media.'.$cw.'x'.$ch.'.crop.'.$ext); $mtime = @filemtime($local); // 0 if not exists - if( $mtime > filemtime($file) || + if( $mtime > @filemtime($file) || media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) || media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){ if($conf['fperm']) chmod($local, $conf['fperm']); |