From: <fg...@us...> - 2011-11-20 16:46:43
|
Revision: 3700 http://openutils.svn.sourceforge.net/openutils/?rev=3700&view=rev Author: fgiust Date: 2011-11-20 16:46:36 +0000 (Sun, 20 Nov 2011) Log Message: ----------- MEDIA-273 new "all" tab Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/css/folderView.css trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-document.png trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-video.png trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-youtube.png trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-all.png Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBean.java 2011-11-20 16:46:36 UTC (rev 3700) @@ -49,12 +49,18 @@ private String previewUrl; + private String dialog; + private Content content; private MetaData metaData; private String uuid; + private String type; + + private String icon; + private List<String> usedInWebPages = new ArrayList<String>(); private List<String> usedInUris = new ArrayList<String>(); @@ -346,4 +352,58 @@ { this.title = title; } + + /** + * Returns the dialog. + * @return the dialog + */ + public String getDialog() + { + return dialog; + } + + /** + * Sets the dialog. + * @param dialog the dialog to set + */ + public void setDialog(String dialog) + { + this.dialog = dialog; + } + + /** + * Returns the type. + * @return the type + */ + public String getType() + { + return type; + } + + /** + * Sets the type. + * @param type the type to set + */ + public void setType(String type) + { + this.type = type; + } + + /** + * Returns the icon. + * @return the icon + */ + public String getIcon() + { + return icon; + } + + /** + * Sets the icon. + * @param icon the icon to set + */ + public void setIcon(String icon) + { + this.icon = icon; + } } \ No newline at end of file Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBeanBuilder.java 2011-11-20 16:46:36 UTC (rev 3700) @@ -31,6 +31,7 @@ import javax.jcr.RepositoryException; +import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaConfigurationManager; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaTypeConfiguration; import net.sourceforge.openutils.mgnlmedia.media.configuration.MediaUsedInManager; import net.sourceforge.openutils.mgnlmedia.media.tags.el.MediaEl; @@ -55,21 +56,21 @@ */ private Logger log = LoggerFactory.getLogger(getClass()); - private final MediaTypeConfiguration mtc; - /** - * - */ - public MediaBeanBuilder(MediaTypeConfiguration mtc) - { - this.mtc = mtc; - } - - /** * {@inheritDoc} */ public MediaBean apply(Content media) { + + String mediatype = media.getNodeData("type").getString(); + MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(mediatype); + + if (mtc == null) + { + log.warn("Skipping media {} with invalid media type \"{}\"", media.getHandle(), mediatype); + return null; + } + MediaBean mb = new MediaBean(); mb.setContent(media); mb.setMetaData(media.getMetaData()); @@ -86,7 +87,10 @@ mb.setThumbnailUrl(mtc.getHandler().getThumbnailUrl(media)); mb.setPreviewUrl(mtc.getHandler().getPreviewUrl(media)); mb.setDescription(mtc.getHandler().getDescription(media)); + mb.setDialog(mtc.getDialog()); mb.setUuid(media.getUUID()); + mb.setType(mediatype); + mb.setIcon(mtc.getMenuIcon()); try { Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.java 2011-11-20 16:46:36 UTC (rev 3700) @@ -143,10 +143,10 @@ } else { - if (StringUtils.isEmpty(type)) - { - type = MediaConfigurationManager.getInstance().getTypes().keySet().iterator().next(); - } + // if (StringUtils.isEmpty(type)) + // { + // type = MediaConfigurationManager.getInstance().getTypes().keySet().iterator().next(); + // } types = MediaConfigurationManager.getInstance().getTypes().values(); } @@ -253,7 +253,6 @@ page); } - return result; } @@ -265,18 +264,22 @@ { // counts media items group by type numberOfMedia = new HashMap<String, Integer>(); + int total = 0; for (MediaTypeConfiguration type : types) { - numberOfMedia.put(type.getName(), countMediaItems(type)); + int countMediaItems = countMediaItems(type); + numberOfMedia.put(type.getName(), countMediaItems); + total += countMediaItems; } + numberOfMedia.put("", total); searchResult = findMediaItems(); if (searchResult != null) { - MediaTypeConfiguration mtc = MediaConfigurationManager.getInstance().getTypes().get(type); + // casts Iterator<AdvancedResultItem> to Iterator<Content> Iterator<Content> contentIterator = Iterators.filter(searchResult.getItems(), Content.class); - medias = Iterators.transform(contentIterator, new MediaBeanBuilder(mtc)); + medias = Iterators.transform(contentIterator, new MediaBeanBuilder()); pages = MgnlPagingElFunctions.pageList(searchResult.getNumberOfPages(), 10, "page"); } if (medias == null) @@ -873,6 +876,11 @@ public String mediatabLink(MediaTypeConfiguration type) { String s = currentQueryString(); + + if (type == null) + { + return '?' + s; + } return '?' + s + (s.length() > 0 ? '&' : StringUtils.EMPTY) + "type=" + type.getName(); } Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/playlist/pages/PlaylistView.java 2011-11-20 16:46:36 UTC (rev 3700) @@ -356,10 +356,7 @@ mediaBeans = new ArrayList<MediaBean>(nodes.size()); for (Content node : nodes) { - MediaTypeConfiguration mtc = MediaConfigurationManager - .getInstance() - .getMediaTypeConfigurationFromMedia(node); - MediaBean bean = new MediaBeanBuilder(mtc).apply(node); + MediaBean bean = new MediaBeanBuilder().apply(node); mediaBeans.add(bean); } } Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/css/folderView.css =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/css/folderView.css 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/css/folderView.css 2011-11-20 16:46:36 UTC (rev 3700) @@ -307,7 +307,7 @@ .mediaheader span.edit { float: right; background: transparent url(images/arrow.gif) no-repeat center right; - padding-right: 12px; + padding-right: 8px; margin-right: 2px; } Added: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-all.png =================================================================== (Binary files differ) Property changes on: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-all.png ___________________________________________________________________ Added: svn:mime-type + image/png Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-document.png =================================================================== (Binary files differ) Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-video.png =================================================================== (Binary files differ) Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/icons/type-youtube.png =================================================================== (Binary files differ) Modified: trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html 2011-11-19 21:44:36 UTC (rev 3699) +++ trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaFolderViewPage.html 2011-11-20 16:46:36 UTC (rev 3700) @@ -93,7 +93,7 @@ var selector = $(e.target); var value = selector.className.match(/pagesize-selector\s+(\w+)(-active)?/)[1]; Cookie.write('pagesizeselector', value, {duration: 30}); - location.href = '?' + [this.options.queryString, 'type=${this.type}'].join('&'); + location.href = '?' + [this.options.queryString, 'type=${this.type!}'].join('&'); } }); @@ -110,7 +110,7 @@ handleSelectChange: function(){ Cookie.write('sorting', this.select.get('value'), {duration: 30}); - location.href = '?' + [this.options.queryString, 'type=${this.type}'].join('&'); + location.href = '?' + [this.options.queryString, 'type=${this.type!}'].join('&'); } }); @@ -240,14 +240,13 @@ </script> <script type="text/javascript"> [#list this.types as type] - [#if type.name == this.type] + [#if type.name == this.type!] [#assign currentType = type] [/#if] [/#list] - function openDialog(path) { - parent.openWindow(".magnolia/dialogs/${currentType.dialog}.html?mgnlPath=" + path - + "&mgnlRepository=media"); + function openDialog(path, dialog) { + parent.openWindow(".magnolia/dialogs/" + dialog + ".html?mgnlPath=" + path + "&mgnlRepository=media"); } function openMediaTree(action, path) { @@ -332,12 +331,11 @@ <input type="hidden" id="actionSearch" name="search" value="${this.search!""}" /> <input type="hidden" id="actionNode" name="node" /> <input type="hidden" id="actionDest" name="dest" /> - <input type="hidden" name="type" value="${this.type}" /> + <input type="hidden" name="type" value="${this.type!}" /> [#if this.request.parameterMap['selectMedia']?exists] <input type="hidden" name="selectMedia" value="true" /> [/#if] <input type="hidden" name="search" value="${this.search!''}" /> - <input type="hidden" name="type" value="${this.type}" /> [#if this.path?exists] <input type="hidden" name="path" value="${this.path}" /> [/#if] @@ -349,8 +347,19 @@ <div class="tabsrow1"> + [#if "" == this.type!] + [#assign actual = "actual"] + [#else] + [#assign actual = ""] + [/#if] + <div class="voice mediatab ${actual}"> + <a href="${this.mediatabLink(null)}"> + <img src="${this.request.contextPath}/.resources/media/icons/type-all.png" alt="${this.msgs.get('media.types.all')}" /> + ${this.msgs.get('media.types.all')} [#if this.numberOfMedia?exists](${this.numberOfMedia[""]!'0'})[/#if] + </a> + </div> [#list this.types as type] - [#if type.name == this.type] + [#if type.name == this.type!] [#assign actual = "actual"] [#else] [#assign actual = ""] @@ -443,14 +452,14 @@ [#if this.selectMedia] [#assign selectMediaClass = "selectMedia"] [/#if] - <li class="media ${mediaStatusClass} ${selectMediaClass}" style="text-align:center"> + <li class="media ${mediaStatusClass} ${selectMediaClass} mediatype-${media.type}" style="text-align:center"> <div class="mediaheader"> - <span class="edit menuitem"> </span> + <span class="edit menuitem"><img src="${this.request.contextPath}${media.icon}" alt="${this.msgs.get('media.types.' + media.type)}" /> </span> <div class="icons menu" style="display: none;"> <ul class="mediamenu"> [#if media.writable] <li> - <a href="javascript:$empty()" onclick="openDialog('${media.handle}')" title="${this.msgs.get('media.edit')}" style="background-image: url('${this.request.contextPath}/.resources/media/icons/ico16-edit.png');"> + <a href="javascript:$empty()" onclick="openDialog('${media.handle}', '${media.dialog}')" title="${this.msgs.get('media.edit')}" style="background-image: url('${this.request.contextPath}/.resources/media/icons/ico16-edit.png');"> ${this.msgs.get('media.edit')} </a> </li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |