summaryrefslogtreecommitdiff
path: root/inc/media.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-04-15 13:45:45 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-04-15 13:45:45 +0200
commitae7c596cf4e6a0a09ebcf01fe8ae98789360c5be (patch)
treef156252e404e9893922cb5d984fdc646644b6c17 /inc/media.php
parentf41c79d730286e8e8c95deb88a4c876e08e278a2 (diff)
parent026b314868ee80aca644bf4107f78d8e8052b43e (diff)
downloadrpg-ae7c596cf4e6a0a09ebcf01fe8ae98789360c5be.tar.gz
rpg-ae7c596cf4e6a0a09ebcf01fe8ae98789360c5be.tar.bz2
Merge branch 'master' into htmlmail
* master: (382 commits) Romanian language update Marathi language update Arabic Language Update when there's not enough space for images, make sure they stay proportional (might be FS#2480) added minimal RTL print styles (part of FS#2185) moved plugins' rtl.css to their style.css counterpart (part of FS#2185) removed all browser-specific gradients as the recently (in 42ff6730) introduced svg makes them unnecessary removed comments from accidentally commented lines in tpl_includeFile() removed obsolete template file added tpl_includeFile() to core Make getTitle method in remote interface public Changed an error code in XML-RPC interface. This error hasn't anything to do with the rest of the -32600 errors. BG: language update Korean language update fixed performance issues with gradient in Firefox (which also added gradient support for IE9) (FS#2447) deleted very old (and unused) images added accidentally removed '<?php' back in (was in 57fc5edd) wrapped X-UA-Compatible meta tag with conditional comments added explanation to todo in _forms.css removed problematic 'overflow: hidden' from lists again ('unfixes' FS#1950) ... Conflicts: inc/auth.php inc/load.php
Diffstat (limited to 'inc/media.php')
-rw-r--r--inc/media.php44
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']);