From: <fg...@us...> - 2010-05-03 10:06:42
|
Revision: 2342 http://openutils.svn.sourceforge.net/openutils/?rev=2342&view=rev Author: fgiust Date: 2010-05-03 10:06:36 +0000 (Mon, 03 May 2010) Log Message: ----------- MEDIA-113 (support old binary nodedatas) + layour of the mediaSelection dialog Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java trunk/openutils-mgnlmedia/src/main/resources/dialog/selectMedia.ftl Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-05-03 10:06:03 UTC (rev 2341) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/dialog/DialogSelectMedia.java 2010-05-03 10:06:36 UTC (rev 2342) @@ -148,9 +148,9 @@ } } - parameters.put("thumbnailUrl", this.getThumbnailUrl(media)); + parameters.put("thumbnailUrl", this.getThumbnailUrl(media, nd)); parameters.put("msgs", this.getMessages()); - parameters.put("filename", this.getFilename(media)); + parameters.put("filename", this.getFilename(media, nd)); if ("true".equals(this.getConfigValue("resizing"))) { @@ -192,21 +192,26 @@ /** * get thumbnail url * @param media + * @param nd * @return thumbnail url */ - public String getThumbnailUrl(Content media) + public String getThumbnailUrl(Content media, NodeData nd) { + if (nd != null && nd.getType() == PropertyType.BINARY) + { + return new FileProperties(getStorageNode(), this.getName()).getProperty(FileProperties.PATH); + } + if (media != null) { MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia( media); return this.getRequest().getContextPath() + mtc.getHandler().getThumbnailUrl(media); } - else - { - return null; - } + + return null; + } /** @@ -224,7 +229,7 @@ if (nd != null && nd.getType() == PropertyType.BINARY) { - return nd.getAttribute(FileProperties.NAME); + return new FileProperties(getStorageNode(), this.getName()).getProperty(FileProperties.PATH); } return super.getValue(); @@ -232,22 +237,29 @@ /** * Filename + * @param nd * @param media2 * @return filename */ - public String getFilename(Content media) + public String getFilename(Content media, NodeData nd) { + if (nd != null && nd.getType() == PropertyType.BINARY) + { + return new FileProperties(getStorageNode(), this.getName()).getProperty(FileProperties.NAME); + } + if (media != null) { MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getMediaTypeConfigurationFromMedia( media); - return mtc.getHandler().getFilename(media); + + String filename = mtc.getHandler().getFilename(media); + return StringUtils.contains(filename, "/") ? StringUtils.substringAfterLast(filename, "/") : filename; } - else - { - return null; - } + + return null; + } public Long getWidth() Modified: trunk/openutils-mgnlmedia/src/main/resources/dialog/selectMedia.ftl =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/dialog/selectMedia.ftl 2010-05-03 10:06:03 UTC (rev 2341) +++ trunk/openutils-mgnlmedia/src/main/resources/dialog/selectMedia.ftl 2010-05-03 10:06:36 UTC (rev 2342) @@ -1,5 +1,6 @@ [#if !alreadyrendered] <script type="text/javascript"> + // <![CDATA[ function selectMedia(name, value, mediaType) { var url = "${request.contextPath}/.magnolia/pages/mediaBrowser.html?nodeid=" + name + "&selectMedia=true&mgnlCK="+ mgnlGetCacheKiller(); @@ -19,7 +20,9 @@ function removeMedia(name) { document.getElementById(name).value = ""; - document.getElementById("dispRem"+ name).style.display = "none"; + document.getElementById("dispRem"+ name + "Img").style.display = "none"; + document.getElementById("dispRemBtn"+ name).style.display = "none"; + document.getElementById("dispRem"+ name + "Txt").innerHTML = ""; document.getElementById("dispSel"+ name).style.display = "block"; } @@ -27,77 +30,89 @@ document.getElementById(name).value = uuid; document.getElementById("dispRem"+ name).style.display = "block"; + document.getElementById("dispRemBtn"+ name).style.display = "block"; document.getElementById("dispSel"+ name).style.display = "none"; document.getElementById("dispRem"+ name + "Img").src = thumbnailurl; + document.getElementById("dispRem"+ name + "Img").style.display = "inline"; document.getElementById("dispRem"+ name + "Txt").innerHTML = filename; } + // ]]> </script> [/#if] -[#if !binaryfield] +[#if !binaryfield?exists] [#assign valuemediacontent = value!'null'] [#else] [#assign valuemediacontent = ''] [/#if] <input type="hidden" id="${name}" name="${name}" value="${valuemediacontent}" /> -[#if !binaryfield && value?exists && value?length > 0] +[#if value?exists && value?length > 0] [#assign dispRem = "block"] [#assign dispSel = "none"] [#else] [#assign dispRem = "none"] [#assign dispSel = "block"] [/#if] -<div id="dispRem${name}" style="display:${dispRem}"> - - - - <div><a href="#" onclick="selectMedia('${name}', '${valuemediacontent}', '${configuration['mediaType']!'null'}')" title="Select media"> - <img id="dispRem${name}Img" src="${thumbnailUrl!''}" border="0" /> - </a> +[#if (configuration['resizing']!false)?string == 'true'] + [#assign dispResize = "block"] +[#else] + [#assign dispResize = "none"] +[/#if] + +<div style="height: 120px;"> + + <div class="medialeft" style="width: 106px; float:left; height: 106px;"> + <div id="dispRem${name}" style="display:${dispRem}"> + <div class="imagebox" + style="width: 106px;height: 106px;border: 1px solid #999; background-image: url(${request.contextPath}/.resources/media/assets/squares.png); text-align: center; vertical-align: middle; "> + <a href="#" onclick="selectMedia('${name}', '${valuemediacontent}', '${configuration['mediaType']!'null'}')" + title="Select media"> + <img id="dispRem${name}Img" src="${thumbnailUrl!''}" style="border: none; display:inline" alt=""/> + </a> + </div> + </div> + <div id="dispRem${name}Txt" style="text-align:center">${filename!''}</div> </div> - <div id="dispRem${name}Txt" > - <a href="#" onclick="selectMedia('${name}', '${valuemediacontent}', '${configuration['mediaType']!'null'}')" title="Seleziona media">${filename!''}</a></div> - <div> - + <div class="mediaright" style="margin-left: 120px;height: 106px;"> - - - - <span class="mgnlControlButton" onclick="mgnlShiftPushButtonClick(this);removeMedia('${name}');" - onmouseout="mgnlShiftPushButtonOut(this);" onmousedown="mgnlShiftPushButtonDown(this);" style=""> - ${msgs.get("media.remove")} - </span> + + + <div> + <div id="dispResize${name}" style="display:${dispResize}"> + <table> + <tbody> + <tr> + <td class="mgnlDialogBoxLabel">Width</td> + <td class="mgnlDialogBoxInput"> + <input type="text" id="${name}_width" name="${name}_width" value="${width!''}" class="mgnlDialogControlEdit" + style="width: 60px;" /> + </td> + </tr> + <tr> + <td class="mgnlDialogBoxLabel">Height</td> + <td class="mgnlDialogBoxInput"> + <input type="text" id="${name}_height" name="${name}_height" value="${height!''}" class="mgnlDialogControlEdit" + style="width: 60px;" /> + </td> + </tr> + </tbody> + </table> + </div> + <div id="dispRemBtn${name}"> + <span class="mgnlControlButton" onclick="mgnlShiftPushButtonClick(this);removeMedia('${name}');" onmouseout="mgnlShiftPushButtonOut(this);" + onmousedown="mgnlShiftPushButtonDown(this);" style="">${msgs.get("media.remove")}</span> + </div> + + <div id="dispSel${name}" style="display:${dispSel}"> + <span class="mgnlControlButton" + onclick="mgnlShiftPushButtonClick(this);selectMedia('${name}', '${valuemediacontent}', '${configuration['mediaType']!'null'}');" + onmouseout="mgnlShiftPushButtonOut(this);" onmousedown="mgnlShiftPushButtonDown(this);" style=""> + ${msgs.get("media.select")}</span> + </div> </div> - [#if (configuration['resizing']!false)?string == 'true'] - [#assign dispResize = "block"] - [#else] - [#assign dispResize = "none"] - [/#if] - <div id="dispResize${name}" style="display:${dispResize}"> - <table> - <tbody> - <tr> - <td class="mgnlDialogBoxLabel">Width</td> - <td class="mgnlDialogBoxInput"> - <input type="text" id="${name}_width" name="${name}_width" value="${width!''}" class="mgnlDialogControlEdit" style="width: 60px;" /> - </td> - </tr> - <tr> - <td class="mgnlDialogBoxLabel">Height</td> - <td class="mgnlDialogBoxInput"> - <input type="text" id="${name}_height" name="${name}_height" value="${height!''}" class="mgnlDialogControlEdit" style="width: 60px;" /> - </td> - </tr> - </tbody> - </table> </div> + </div> -<div id="dispSel${name}" style="display:${dispSel}"> - <span class="mgnlControlButton" onclick="mgnlShiftPushButtonClick(this);selectMedia('${name}', '${valuemediacontent}', '${configuration['mediaType']!'null'}');" - onmouseout="mgnlShiftPushButtonOut(this);" onmousedown="mgnlShiftPushButtonDown(this);" style=""> - ${msgs.get("media.select")} - </span> -</div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |