From cf6894df38261b3b92c75d441bbe0a0ba58d963e Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Thu, 25 May 2006 16:40:00 +0200
Subject: [PATCH] more mediamanager fixes

This fixes some styling issues, the cookie handling and a bug in the
JavaScript caching mechanism.

darcs-hash:20060525144000-7ad00-2f0b673d4f747c979f460e4e927a50eeeae81ec1.gz
---
 inc/lang/en/lang.php             |   6 ++--
 inc/media.php                    |  13 ++++++--
 lib/exe/css.php                  |   1 +
 lib/exe/js.php                   |   3 +-
 lib/exe/mediamanager.php         |   2 +-
 lib/images/magnifier.png         | Bin 0 -> 615 bytes
 lib/scripts/media.js             |   4 ++-
 lib/tpl/default/media.css        |  53 +++++++++++++++++++++++++++----
 lib/tpl/default/mediamanager.php |   4 +--
 9 files changed, 70 insertions(+), 16 deletions(-)
 create mode 100644 lib/images/magnifier.png

diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 49f9676ae..c5584113b 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -91,8 +91,8 @@ $lang['notsavedyet'] = 'Unsaved changes will be lost.\nReally continue?';
 $lang['rssfailed']   = 'An error occured while fetching this feed: ';
 $lang['nothingfound']= 'Nothing was found.';
 
-$lang['mediaselect'] = 'Mediafiles';
-$lang['fileupload']  = 'Mediafile Upload';
+$lang['mediaselect'] = 'Media Files';
+$lang['fileupload']  = 'Media File Upload';
 $lang['uploadsucc']  = 'Upload successful';
 $lang['uploadfail']  = 'Upload failed. Maybe wrong permissions?';
 $lang['uploadwrong'] = 'Upload denied. This file extension is forbidden!';
@@ -106,6 +106,8 @@ $lang['mediafiles']  = 'Available files in';
 $lang['js']['keepopen']    = 'Keep window open on selection';
 $lang['js']['hidedetails'] = 'Hide Details';
 $lang['mediausage']  = 'Use the following syntax to reference this file:';
+$lang['mediaview']   = 'View original file';
+$lang['mediaupload'] = 'Upload a file to the current namespace here. To create subnamespaces, prepend them to your filename separated by colons.';
 
 $lang['reference']   = 'References for';
 $lang['ref_inuse']   = 'The file can\'t be deleted, because it\'s still used by the following pages:';
diff --git a/inc/media.php b/inc/media.php
index f09aff2eb..7d2dbd5ff 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -114,7 +114,7 @@ function media_metaform($id,$auth){
         echo '<div class="metafield">';
         echo '<label for="meta__'.$key.'">';
         echo ($lang[$field[1]]) ? $lang[$field[1]] : $field[1];
-        echo '</label>';
+        echo ':</label>';
 
         // put input field
         if($field[2] == 'text'){
@@ -268,7 +268,13 @@ function media_filelist($ns,$auth=null,$jump=''){
 function media_fileactions($item,$auth){
     global $lang;
 
-    // no actions if not writable
+    // view button
+    $link = ml($item['id'],'',true);
+    echo ' <a href="'.$link.'" target="_blank"><img src="'.DOKU_BASE.'lib/images/magnifier.png" '.
+         'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /></a>';
+
+
+    // no further actions if not writable
     if(!$item['writable']) return;
 
     // delete button
@@ -377,6 +383,7 @@ function media_printimgdetail($item){
     $t = $item['meta']->getField(array('IPTC.Caption','EXIF.UserComment',
                                        'EXIF.TIFFImageDescription',
                                        'EXIF.TIFFUserComment'));
+    if(utf8_strlen($t) > 250) $t = utf8_substr($t,0,250).'...';
     if($t) echo htmlspecialchars($t).'<br />';
 
     $t = $item['meta']->getField(array('IPTC.Keywords','IPTC.Category'));
@@ -396,10 +403,12 @@ function media_uploadform($ns, $auth){
     if($auth < AUTH_UPLOAD) return; //fixme print info on missing permissions?
 
     ?>
+    <div class="upload"><?php echo $lang['mediaupload']?></div>
     <form action="<?php echo DOKU_BASE?>lib/exe/mediamanager.php"
           method="post" enctype="multipart/form-data" class="upload">
         <input type="hidden" name="ns" value="<?php echo hsc($ns)?>" />
 
+
         <?php echo $lang['txt_upload']?>:
         <input type="file" name="upload" class="edit" id="upload__file" /><br />
 
diff --git a/lib/exe/css.php b/lib/exe/css.php
index b63841a03..cb85d1a35 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -72,6 +72,7 @@ function css_out(){
     header('Pragma: public');
     if(css_cacheok($cache,array_keys($files))){
         http_conditionalRequest(filemtime($cache));
+        if($conf['allowdebug']) header("X-CacheUsed: $cache");
         readfile($cache);
         return;
     } else {
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 583faa5ad..7ff60710c 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -35,7 +35,7 @@ function js_out(){
     $write = (bool) $_REQUEST['write'];  // writable?
 
     // The generated script depends on some dynamic options
-    $cache = getCacheName('scripts'.$edit.$write,'.js'); 
+    $cache = getCacheName('scripts'.$edit.'x'.$write,'.js'); 
 
     // Array of needed files
     $files = array(
@@ -66,6 +66,7 @@ function js_out(){
     header('Pragma: public');
     if(js_cacheok($cache,array_merge($files,$plugins))){
         http_conditionalRequest(filemtime($cache));
+        if($conf['allowdebug']) header("X-CacheUsed: $cache");
         readfile($cache);
         return;
     } else {
diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php
index 23140ee3c..b381fabf6 100644
--- a/lib/exe/mediamanager.php
+++ b/lib/exe/mediamanager.php
@@ -1,4 +1,4 @@
-<?
+<?php
     if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
     define('DOKU_MEDIAMANAGER',1);
     require_once(DOKU_INC.'inc/init.php');
diff --git a/lib/images/magnifier.png b/lib/images/magnifier.png
new file mode 100644
index 0000000000000000000000000000000000000000..cf3d97f75e9cde9c143980d89272fe61fc2d64ee
GIT binary patch
literal 615
zcmV-t0+{`YP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUz`AI}UR5;6}
zlD}({VGzf^?~f!#tf`u$5Q9JHQ1uTGDng(|aLClHAP#~!RCnFF2#yY>gNuvOO$0ks
zMIj=HnnBRUR?tKXG11rxCU4&7dG4NbuvR2_mEvc)n?Cow;~Wve|KR^>9@p5l)|QB+
z$jmun3q#x>;ss-PW_mnr2MHVzLAl1RW&0?VkixF*4t!St0YVb2wnKdU(kmOHiL;aW
zK8Xte%(k>MVGG$E4no6dcNnb>BhVHHGD&1pv4YZ68kE2V03t5#PCEFm7=ad$6)+3B
zTCmn*?A?=u(o~ET7~-7g0)ZB=6|lumi4}B}MLgy~Ysy6)Q5%Al7|05&1z3Jpu>cF8
z3?VXs*3<}%h3`5Wld)N2zJnk%Agw<~3k)sPTLFd=F5;d8-bj-09SkQuynfflNcZLN
z!^_37fdZvzrq=9~mp*($%mcDRKC&qvaaZuX+C=AT6O*~tHl>0mcP<_q>-z%$xO(@!
zYluq5a8VQI$S@4?r*v;gPo!QQ%pX3A#>xx4t=w-L6COWx?aj&`f+!YePsFtj=hOQR
zP3=E2j@9L7s8;T^&s?u(Hdpu?CubjMrGn{t_37>9$|AD)QE08weJlKn8|OyjL~7oP
zC8mPT`jzuH*Dh^I0048RGafUIT)4H~*m8m>egI0iH=(LB%b@@O002ovPDHLkV1lw0
B3<CfF

literal 0
HcmV?d00001

diff --git a/lib/scripts/media.js b/lib/scripts/media.js
index 876b84f9f..da030be28 100644
--- a/lib/scripts/media.js
+++ b/lib/scripts/media.js
@@ -73,7 +73,8 @@ media = {
             kobox.type = 'checkbox';
             kobox.id   = 'media__keepopen';
             if(DokuCookie.getValue('keepopen')){
-                kobox.checked = true;
+                kobox.checked  = true;
+                media.keepopen = true;
             }
             addEvent(kobox,'change',function(event){ return media.togglekeepopen(event,this); });
 
@@ -94,6 +95,7 @@ media = {
         hdbox.id   = 'media__hide';
         if(DokuCookie.getValue('hide')){
             hdbox.checked = true;
+            media.hide    = true;
         }
         addEvent(hdbox,'change',function(event){ return media.togglehide(event,this); });
 
diff --git a/lib/tpl/default/media.css b/lib/tpl/default/media.css
index 805abc467..4606cae45 100644
--- a/lib/tpl/default/media.css
+++ b/lib/tpl/default/media.css
@@ -4,7 +4,7 @@
 
 #media__manager {
     height: 100%;
-    overflow: hide;
+    overflow: hidden;
 }
 
 #media__left {
@@ -18,7 +18,7 @@
 }
 
 #media__right {
-    width: 69.9%;
+    width: 69.8%;
 
     height: 100%;
     overflow: auto;
@@ -26,6 +26,14 @@
     right: 0;
 }
 
+#media__manager h1 {
+    margin: 0;
+    padding: 0;
+    margin-bottom: 0.5em;
+}
+
+/* --- Tree formatting --- */
+
 #media__tree img {
     float:left;
     padding: 0.5em 0.3em 0 0;
@@ -42,6 +50,28 @@
     list-style-image: none;
 }
 
+/* --- options --- */
+
+#media__opts {
+    padding-left: 1em;
+    margin-bottom: 0.5em;
+}
+
+#media__opts input {
+    float: left;
+    position: absolute;
+}
+
+#media__opts label {
+    display: block;
+    float: left;
+    margin-left: 30px;
+}
+
+#media__opts br {
+    clear: left;
+}
+
 /* --- file list --- */
 
 #media__content img.load {
@@ -89,6 +119,11 @@
 
 /* --- upload form --- */
 
+#media__content div.upload {
+    font-size: 80%;
+    padding: 0.5em 0 0.5em 0.5em;
+}
+
 #media__content form.upload {
     display: block;
     border-bottom: solid 1px __dark__;
@@ -104,20 +139,24 @@
 
 #media__content form.meta label {
     display: block;
-    width: 20%;
+    width: 25%;
     float: left;
-    text-align: right;
     font-weight: bold;
-    padding-right: 1em;
+    margin-left: 1em;
+    clear: left;
 }
 
 #media__content form.meta .edit {
+    font: 100% "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
     float: left;
-    width: 75%;
+    width: 70%;
+    padding-right: 0;
+    padding-left: 0.2em;
+    margin: 2px;
 }
 
 #media__content form.meta textarea.edit {
-    height: 6em;
+    height: 8em;
 }
 
 #media__content form.meta div.metafield {
diff --git a/lib/tpl/default/mediamanager.php b/lib/tpl/default/mediamanager.php
index 0ae4f7c66..2b032ac46 100644
--- a/lib/tpl/default/mediamanager.php
+++ b/lib/tpl/default/mediamanager.php
@@ -27,10 +27,10 @@
         <?html_msgarea()?>
         <h1><?php echo hsc($lang['mediaselect'])?></h1>
 
-        <?php tpl_mediaTree() ?>
-
         <?php /* keep the id! additional elements are inserted via JS here */?>
         <div id="media__opts"></div>
+
+        <?php tpl_mediaTree() ?>
     </div>
 
     <div id="media__right">
-- 
GitLab