Index: branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/java/org/sakaiproject/content/tool/FilePickerAction.java =================================================================== --- branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/java/org/sakaiproject/content/tool/FilePickerAction.java (revision 387) +++ branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/java/org/sakaiproject/content/tool/FilePickerAction.java (revision 694) @@ -26,11 +26,11 @@ import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; -import java.util.Hashtable; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -48,5 +48,4 @@ import org.apache.commons.logging.LogFactory; import org.sakaiproject.authz.api.SecurityAdvisor; -import org.sakaiproject.authz.api.SecurityAdvisor.SecurityAdvice; import org.sakaiproject.authz.cover.SecurityService; import org.sakaiproject.cheftool.Context; @@ -55,5 +54,4 @@ import org.sakaiproject.cheftool.RunData; import org.sakaiproject.cheftool.VelocityPortlet; -import org.sakaiproject.cheftool.VelocityPortletPaneledAction; import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.component.cover.ServerConfigurationService; @@ -61,7 +59,9 @@ import org.sakaiproject.content.api.ContentCollectionEdit; import org.sakaiproject.content.api.ContentEntity; +import org.sakaiproject.content.api.ContentHostingService; import org.sakaiproject.content.api.ContentResource; import org.sakaiproject.content.api.ContentResourceEdit; import org.sakaiproject.content.api.ContentResourceFilter; +import org.sakaiproject.content.api.ContentTypeImageService; import org.sakaiproject.content.api.FilePickerHelper; import org.sakaiproject.content.api.InteractionAction; @@ -70,8 +70,9 @@ import org.sakaiproject.content.api.ResourceType; import org.sakaiproject.content.api.ResourceTypeRegistry; -import org.sakaiproject.content.api.ContentHostingService; -import org.sakaiproject.content.api.ContentTypeImageService; import org.sakaiproject.content.api.ServiceLevelAction; import org.sakaiproject.content.api.GroupAwareEntity.AccessMode; +import org.sakaiproject.content.tool.ResourcesAction.ChefPathItem; +import org.sakaiproject.entity.api.EntityPropertyNotDefinedException; +import org.sakaiproject.entity.api.EntityPropertyTypeException; import org.sakaiproject.entity.api.Reference; import org.sakaiproject.entity.api.ResourceProperties; @@ -931,4 +932,8 @@ state.removeAttribute(STATE_NEED_TO_EXPAND_ALL); + + List cPath = getCollectionPath(state); + context.put ("collectionPath", cPath); + // inform the observing courier that we just updated the page... // if there are pending requests to do so they can be cleared @@ -1190,5 +1195,4 @@ toolSession.setAttribute(STATE_SESSION_INITIALIZED, Boolean.TRUE); } - } // initState @@ -3301,4 +3305,6 @@ if (state.getAttribute(STATE_MESSAGE) == null) { + state.setAttribute(STATE_COLLECTION_ID, collectionId); + SortedSet currentMap = (SortedSet) state.getAttribute(STATE_EXPANDED_COLLECTIONS); if(currentMap == null) @@ -3373,3 +3379,115 @@ } + + // --------------------------- + + /** The collection id being browsed. */ + private static final String STATE_COLLECTION_ID = PREFIX /*+ REQUEST */+ "collection_id"; + + /** + * @param state + * @param homeCollectionId + * @param currentCollectionId + * @return + */ + public static List getCollectionPath(SessionState state) + { + logger.debug("ResourcesAction.getCollectionPath()"); + org.sakaiproject.content.api.ContentHostingService contentService = (org.sakaiproject.content.api.ContentHostingService) state.getAttribute (STATE_CONTENT_SERVICE); + // make sure the channedId is set + String currentCollectionId = (String) state.getAttribute (STATE_COLLECTION_ID); + String homeCollectionId = (String) state.getAttribute(STATE_HOME_COLLECTION_ID); + String navRoot = (String) state.getAttribute(STATE_NAVIGATION_ROOT); + + LinkedList collectionPath = new LinkedList(); + + String previousCollectionId = ""; + List pathitems = new ArrayList(); + while ((currentCollectionId != null) && (!currentCollectionId.equals(navRoot)) && (!currentCollectionId.equals(previousCollectionId)) + && !(contentService.ROOT_COLLECTIONS.contains(currentCollectionId)) && (!contentService.isRootCollection(previousCollectionId))) + { + pathitems.add(currentCollectionId); + previousCollectionId = currentCollectionId; + currentCollectionId = contentService.getContainingCollectionId(currentCollectionId); + } + + if(navRoot != null && (pathitems.isEmpty() || (! navRoot.equals(previousCollectionId) && ! navRoot.equals(currentCollectionId)))) + { + pathitems.add(navRoot); + + } + if(homeCollectionId != null && (pathitems.isEmpty() || (!homeCollectionId.equals(navRoot) && ! homeCollectionId.equals(previousCollectionId) && ! homeCollectionId.equals(currentCollectionId)))) + { + pathitems.add(homeCollectionId); + } + + Iterator items = pathitems.iterator(); + while(items.hasNext()) + { + String id = (String) items.next(); + try + { + ResourceProperties props = contentService.getProperties(id); + String name = props.getPropertyFormatted(ResourceProperties.PROP_DISPLAY_NAME); + String containingCollectionId = contentService.getContainingCollectionId(id); + if(contentService.COLLECTION_DROPBOX.equals(containingCollectionId)) + { + Reference ref = EntityManager.newReference(contentService.getReference(id)); + Site site = SiteService.getSite(ref.getContext()); + String[] args = {site.getTitle()}; + name = trb.getFormattedMessage("title.dropbox", args); + } + else if(contentService.COLLECTION_SITE.equals(containingCollectionId)) + { + Reference ref = EntityManager.newReference(contentService.getReference(id)); + Site site = SiteService.getSite(ref.getContext()); + String[] args = {site.getTitle()}; + name = trb.getFormattedMessage("title.resources", args); + } + + ChefPathItem item = new ChefPathItem(id, name); + + boolean canRead = contentService.allowGetCollection(id) || contentService.allowGetResource(id); + item.setCanRead(canRead); + + if(canRead) + { + String url = contentService.getUrl(id); + item.setUrl(url); + } + + item.setLast(collectionPath.isEmpty()); + if(id.equals(homeCollectionId)) + { + item.setRoot(homeCollectionId); + } + else + { + item.setRoot(navRoot); + } + + try + { + boolean isFolder = props.getBooleanProperty(ResourceProperties.PROP_IS_COLLECTION); + item.setIsFolder(isFolder); + } + catch (EntityPropertyNotDefinedException e1) + { + } + catch (EntityPropertyTypeException e1) + { + } + + collectionPath.addFirst(item); + + } + catch (PermissionException e) + { + } + catch (IdUnusedException e) + { + } + } + return collectionPath; + } } // class FilePickerAction Index: branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/webapp/vm/content/sakai_filepicker_attach.vm =================================================================== --- branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/webapp/vm/content/sakai_filepicker_attach.vm (revision 389) +++ branches/Cambro_Sakai_2-6-0/content/content-tool/tool/src/webapp/vm/content/sakai_filepicker_attach.vm (revision 694) @@ -49,4 +49,10 @@ + + + + + + #if($attached.isEmpty()) #else @@ -102,4 +108,13 @@
+ ###################### Find top level + #set($topItem = "") + #set($collectionPathSize = 0) + #foreach ($item in $collectionPath) + #set($collectionPathSize = $collectionPathSize + 1) + #end + #if($collectionPathSize > 1) + #set($topItem = $collectionPath.get(1).id) + #end ###################### Page Title / Breadcrumbs ##############
@@ -111,4 +126,5 @@ $tlang.getString("gen.location") $tlang.getString('gen.folder1') + #foreach ($item in $collectionPath) #if($item.isLast()) @@ -127,5 +143,5 @@ #end -
+ ###################### Heirarchical list of resource folders/items ############## @@ -158,4 +174,5 @@ + #set ($unit = "em") #foreach($item in $this_site) @@ -187,5 +204,5 @@ $validator.escapeHtml(${item.name}) #elseif ($item.canRead()) - #if (!$expandedCollections.containsKey($item.Id)) + #if (!$expandedCollections.contains($item.Id)) $tlang.getString('sh.open') @@ -242,5 +259,5 @@ #end #end - #end + #end @@ -354,5 +371,5 @@ $validator.escapeHtml(${root.name}) #elseif ($root.canRead()) - #if (!$expandedCollections.containsKey($root.Id)) + #if (!$expandedCollections.contains($root.Id)) $tlang.getString('sh.open')