diff --git a/content/content-tool/tool/src/java/org/sakaiproject/content/entityproviders/ContentEntityProvider.java b/content/content-tool/tool/src/java/org/sakaiproject/content/entityproviders/ContentEntityProvider.java index d0c1f6cca39e..b93b4aea424b 100644 --- a/content/content-tool/tool/src/java/org/sakaiproject/content/entityproviders/ContentEntityProvider.java +++ b/content/content-tool/tool/src/java/org/sakaiproject/content/entityproviders/ContentEntityProvider.java @@ -1,9 +1,5 @@ package org.sakaiproject.content.entityproviders; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; import java.net.URI; import java.util.ArrayList; import java.util.Comparator; @@ -17,8 +13,6 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.sakaiproject.authz.api.SecurityService; import org.sakaiproject.component.cover.ComponentManager; import org.sakaiproject.content.api.ContentCollection; @@ -27,13 +21,13 @@ import org.sakaiproject.content.api.ContentResource; import org.sakaiproject.content.api.ResourceTypeRegistry; import org.sakaiproject.content.tool.ListItem; -import org.sakaiproject.entity.api.EntityManager; -import org.sakaiproject.entity.api.EntityPermissionException; -import org.sakaiproject.entity.api.Reference; import org.sakaiproject.entity.api.ResourceProperties; import org.sakaiproject.entitybroker.EntityView; import org.sakaiproject.entitybroker.entityprovider.EntityProvider; import org.sakaiproject.entitybroker.entityprovider.annotations.EntityCustomAction; +import org.sakaiproject.entitybroker.entityprovider.annotations.EntityId; +import org.sakaiproject.entitybroker.entityprovider.annotations.EntityOwner; +import org.sakaiproject.entitybroker.entityprovider.annotations.EntityTitle; import org.sakaiproject.entitybroker.entityprovider.capabilities.ActionsExecutable; import org.sakaiproject.entitybroker.entityprovider.capabilities.AutoRegisterEntityProvider; import org.sakaiproject.entitybroker.entityprovider.capabilities.Describeable; @@ -41,8 +35,6 @@ import org.sakaiproject.entitybroker.entityprovider.extension.Formats; import org.sakaiproject.entitybroker.exception.EntityNotFoundException; import org.sakaiproject.entitybroker.util.AbstractEntityProvider; -import org.sakaiproject.entitybroker.util.EntityDataUtils; -import org.sakaiproject.entitybroker.util.model.EntityContent; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.exception.PermissionException; import org.sakaiproject.exception.ServerOverloadException; @@ -50,8 +42,6 @@ import org.sakaiproject.site.api.Site; import org.sakaiproject.site.api.SiteService; import org.sakaiproject.site.api.ToolConfiguration; -import org.sakaiproject.time.api.Time; -import org.sakaiproject.time.cover.TimeService; import org.sakaiproject.tool.api.ToolManager; import org.sakaiproject.tool.api.Session; import org.sakaiproject.tool.cover.SessionManager; @@ -69,9 +59,6 @@ public class ContentEntityProvider extends AbstractEntityProvider implements Ent public static final String PREFIX = "resources."; public static final String SYS = "sys."; private static final String STATE_RESOURCES_TYPE_REGISTRY = PREFIX + SYS + "type_registry"; - private static Log log = LogFactory.getLog(ContentEntityProvider.class); - private static final String PARAMETER_DEPTH = "depth"; - private static final String PARAMETER_TIMESTAMP = "timestamp"; @Override public String getEntityPrefix() { @@ -165,183 +152,7 @@ public List getContentCollectionForSite(EntityView view) { return getSiteListItems(siteId); } - @EntityCustomAction(action="resources", viewKey=EntityView.VIEW_LIST) - public List getResources(EntityView view, Map params) - throws EntityPermissionException { - String userId = developerHelperService.getCurrentUserId(); - if (userId == null) { - throw new SecurityException( - "This action is not accessible to anon and there is no current user."); - } - - Map parameters = getQueryMap((String)params.get("queryString")); - Time timeStamp = getTime((String)parameters.get(PARAMETER_TIMESTAMP)); - - int requestedDepth = 1; - int currentDepth = 0; - if (parameters.containsKey(PARAMETER_DEPTH)) { - if ("all".equals((String)parameters.get(PARAMETER_DEPTH))) { - requestedDepth = Integer.MAX_VALUE; - } else { - requestedDepth = Integer.parseInt((String)parameters.get(PARAMETER_DEPTH)); - } - } - - String[] segments = view.getPathSegments(); - - StringBuffer resourceId = new StringBuffer(); - for (int i=2; i resourceDetails = new ArrayList(); - if (collection!=null) { - EntityContent resourceDetail = getResourceDetails(collection, currentDepth, requestedDepth, timeStamp); - if (resourceDetail != null) { - resourceDetails.add(resourceDetail); - } else { - log.error("Initial permission check passed but subsequent permission check failed on "+ reference.getId()); - } - } - return resourceDetails; - } - - /** - * - * @param entity The entity to load details of. - * @param currentDepth How many collections we have already processed - * @param requestedDepth The maximum number depth of the tree to scan. - * @param timeStamp All returned details must be newer than this timestamp. - * @return EntityContent containing details of all resources the user can access. - * null is returned if the current user isn't allowed to access the resource. - */ - private EntityContent getResourceDetails( - ContentEntity entity, int currentDepth, int requestedDepth, Time timeStamp) { - boolean allowed = (entity.isCollection()) ? - contentHostingService.allowGetCollection(entity.getId()) : - contentHostingService.allowGetResource(entity.getId()); - if (!allowed) { - // If the user isn't allowed to see this we return null. - return null; - } - EntityContent tempRd = EntityDataUtils.getResourceDetails(entity); - - // If it's a collection recurse down into it. - if ((requestedDepth > currentDepth) && entity.isCollection()) { - - ContentCollection collection = (ContentCollection)entity; - // This is all members, no permission check has been done yet. - List contents = collection.getMemberResources(); - - Comparator comparator = getComparator(entity); - if (null != comparator) { - Collections.sort(contents, comparator); - } - - for (Iterator i = contents.iterator(); i.hasNext();) { - ContentEntity content = i.next(); - EntityContent resource = getResourceDetails(content, currentDepth+1, requestedDepth, timeStamp); - - if (resource != null && resource.after(timeStamp)) { - tempRd.addResourceChild(resource); - } - } - } - - return tempRd; - } - - /** - * - * @param entity - * @return - */ - private Comparator getComparator(ContentEntity entity) { - - boolean hasCustomSort = false; - try { - hasCustomSort = entity.getProperties().getBooleanProperty( - ResourceProperties.PROP_HAS_CUSTOM_SORT); - - } catch(Exception e) { - // ignore -- let value of hasCustomSort stay false - } - - if(hasCustomSort) { - return contentHostingService.newContentHostingComparator( - ResourceProperties.PROP_CONTENT_PRIORITY, true); - } else { - return contentHostingService.newContentHostingComparator( - ResourceProperties.PROP_DISPLAY_NAME, true); - } - } - - /** - * - * @param queryString - * @return - */ - private Map getQueryMap(String queryString) { - - Map params = new HashMap(); - if (null != queryString && !queryString.isEmpty()) { - String[] strings = queryString.split("&"); - for (int i=0; i getSiteListItems(String siteId) { List rv = new ArrayList(); String wsCollectionId = contentHostingService.getSiteCollection(siteId); @@ -714,8 +525,6 @@ public String[] getHandledOutputFormats() { @Setter private UserDirectoryService userDirectoryService; - @Setter - private EntityManager entityManager; diff --git a/content/content-tool/tool/src/webapp/WEB-INF/applicationContext.xml b/content/content-tool/tool/src/webapp/WEB-INF/applicationContext.xml index 1c011dc9e1f8..29982ad047e0 100644 --- a/content/content-tool/tool/src/webapp/WEB-INF/applicationContext.xml +++ b/content/content-tool/tool/src/webapp/WEB-INF/applicationContext.xml @@ -22,7 +22,6 @@ - diff --git a/entitybroker/rest/pom.xml b/entitybroker/rest/pom.xml index 7596beaff68b..d26d91c91dc7 100644 --- a/entitybroker/rest/pom.xml +++ b/entitybroker/rest/pom.xml @@ -26,10 +26,6 @@ org.sakaiproject.entitybroker entitybroker-utils - - org.sakaiproject.kernel - sakai-kernel-api - org.sakaiproject.entitybroker diff --git a/entitybroker/utils/pom.xml b/entitybroker/utils/pom.xml index 5d0281f814f7..f6db58a90481 100644 --- a/entitybroker/utils/pom.xml +++ b/entitybroker/utils/pom.xml @@ -46,10 +46,6 @@ org.sakaiproject.kernel sakai-component-manager - - org.sakaiproject.kernel - sakai-kernel-api - org.azeckoski diff --git a/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/EntityDataUtils.java b/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/EntityDataUtils.java index 21f08cdcd9a7..daa5c928770b 100644 --- a/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/EntityDataUtils.java +++ b/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/EntityDataUtils.java @@ -21,17 +21,15 @@ package org.sakaiproject.entitybroker.util; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.Map.Entry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.azeckoski.reflectutils.ReflectUtils; import org.azeckoski.reflectutils.exceptions.FieldnameNotFoundException; -import org.sakaiproject.content.api.ContentEntity; -import org.sakaiproject.entity.api.EntityPropertyNotDefinedException; -import org.sakaiproject.entity.api.EntityPropertyTypeException; -import org.sakaiproject.entity.api.ResourceProperties; import org.sakaiproject.entitybroker.EntityReference; import org.sakaiproject.entitybroker.entityprovider.annotations.EntityId; import org.sakaiproject.entitybroker.entityprovider.capabilities.CollectionResolvable; @@ -39,7 +37,6 @@ import org.sakaiproject.entitybroker.entityprovider.extension.EntityData; import org.sakaiproject.entitybroker.entityprovider.search.Restriction; import org.sakaiproject.entitybroker.entityprovider.search.Search; -import org.sakaiproject.entitybroker.util.model.EntityContent; /** @@ -49,24 +46,6 @@ */ public class EntityDataUtils { - private final static Log log = LogFactory.getLog(EntityDataUtils.class); - // Property names - private final static Set directPropertyNames = Collections.unmodifiableSet(new HashSet(){ - private static final long serialVersionUID = 1L; - { - add(ResourceProperties.PROP_DISPLAY_NAME); - add(ResourceProperties.PROP_DESCRIPTION); - add(ResourceProperties.PROP_CREATOR); - add(ResourceProperties.PROP_MODIFIED_BY); - add(ResourceProperties.PROP_CREATION_DATE); - add(ResourceProperties.PROP_MODIFIED_DATE); - add(ResourceProperties.PROP_RESOURCE_TYPE); - add(ResourceProperties.PROP_CONTENT_TYPE); - add(ResourceProperties.PROP_CONTENT_PRIORITY); - add(ResourceProperties.PROP_CONTENT_LENGTH); - add(ResourceProperties.PROP_IS_COLLECTION); - } - }); /** * Convert a list of objects to entity data objects (DOES NOT populate them), * will preserve null (i.e. null in => null out) @@ -375,62 +354,5 @@ public static Map extractMapProperties(Map m) { } return props; } - /** - * Produces a summary of an content entity for display in entitybroker. - * @param entity The entity to display. - * @return An EntityContent matching the supplied entity. - */ - public static EntityContent getResourceDetails(ContentEntity entity) { - - EntityContent tempRd = new EntityContent(); - - ResourceProperties properties = entity.getProperties(); - Iterator propertyNames = properties.getPropertyNames(); - while (propertyNames.hasNext()) { - String key = (String) propertyNames.next(); - if (!directPropertyNames.contains(key)) { - String value = properties.getProperty(key); - if (null != value) { - tempRd.setProperty(key, value); - } - } - } - - tempRd.setResourceId(entity.getId()); - tempRd.setName(properties - .getPropertyFormatted(ResourceProperties.PROP_DISPLAY_NAME)); - tempRd.setDescription(properties - .getProperty(ResourceProperties.PROP_DESCRIPTION)); - tempRd.setCreator(properties - .getProperty(ResourceProperties.PROP_CREATOR)); - - tempRd.setModifiedBy(properties - .getProperty(ResourceProperties.PROP_MODIFIED_BY)); - tempRd.setMimeType(properties - .getProperty(ResourceProperties.PROP_CONTENT_TYPE)); - tempRd.setPriority(properties - .getProperty(ResourceProperties.PROP_CONTENT_PRIORITY)); - tempRd.setSize(properties - .getProperty(ResourceProperties.PROP_CONTENT_LENGTH)); - tempRd.setReference(entity.getReference()); - tempRd.setType(entity.getResourceType()); - tempRd.setUrl(entity.getUrl()); - tempRd.setRelease(entity.getReleaseDate()); - tempRd.setRetract(entity.getRetractDate()); - tempRd.setHidden(entity.isHidden()); - try { - tempRd.setCreated(properties - .getTimeProperty(ResourceProperties.PROP_CREATION_DATE)); - tempRd.setModified(properties - .getTimeProperty(ResourceProperties.PROP_MODIFIED_DATE)); - - } catch (EntityPropertyNotDefinedException e) { - log.warn("Failed to get property on " + entity.getId(), e); - } catch (EntityPropertyTypeException e) { - log.warn("Incorrect property type on " + entity.getId(), e); - } - - return tempRd; - } } diff --git a/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/model/EntityContent.java b/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/model/EntityContent.java deleted file mode 100644 index 02fd59e142f5..000000000000 --- a/entitybroker/utils/src/java/org/sakaiproject/entitybroker/util/model/EntityContent.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.sakaiproject.entitybroker.util.model; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.sakaiproject.time.api.Time; - -public class EntityContent { - - private String name; - private String resourceId; - private String reference; - private String type; - private String mimeType; - private String description; - private String creator; - private String modifiedBy; - private String size; - private String url; - private String priority; - - private Time created; - private Time modified; - private Time release; - private Time retract; - - private boolean hidden; - - private Collection resourceChildren = new ArrayList(); - - private Map properties = new HashMap(); - - public void setName(String name) { - this.name = name; - } - public String getName() { - return name; - } - public void setResourceId(String id) { - this.resourceId = id; - } - public String getResourceId() { - return resourceId; - } - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - public String getMimeType() { - return mimeType; - } - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getSize() { - return size; - } - public void setSize(String size) { - this.size = size; - } - public String getCreator() { - return creator; - } - public void setCreator(String creator) { - this.creator = creator; - } - public String getModifiedBy() { - return modifiedBy; - } - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - public Long getCreated() { - return created.getTime(); - } - public void setCreated(Time created) { - this.created = created; - } - public Long getModified() { - return modified.getTime(); - } - public void setModified(Time modified) { - this.modified = modified; - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - public String getReference() { - return reference; - } - public void setReference(String reference) { - this.reference = reference; - } - public String getPriority() { - return priority; - } - public void setPriority(String priority) { - this.priority = priority; - } - public Long getRelease() { - return release.getTime(); - } - public void setRelease(Time release) { - this.release = release; - } - public Long getRetract() { - return retract.getTime(); - } - public void setRetract(Time retract) { - this.retract = retract; - } - public boolean getHidden() { - return hidden; - } - public void setHidden(boolean hidden) { - this.hidden = hidden; - } - public void addResourceChild(EntityContent child) { - this.resourceChildren.add(child); - } - public Collection getResourceChildren() { - return resourceChildren; - } - - public Map getProperties() { - return properties; - } - public void setProperty(String key, Object value) { - properties.put(key, value); - } - - public boolean after(Time timeStamp) { - if (modified.after(timeStamp)) { - return true; - } - return false; - } -} diff --git a/lessonbuilder/api/src/java/org/sakaiproject/lessonbuildertool/SimplePageItem.java b/lessonbuilder/api/src/java/org/sakaiproject/lessonbuildertool/SimplePageItem.java index 75526dd25405..ddbbaedf0b66 100644 --- a/lessonbuilder/api/src/java/org/sakaiproject/lessonbuildertool/SimplePageItem.java +++ b/lessonbuilder/api/src/java/org/sakaiproject/lessonbuildertool/SimplePageItem.java @@ -47,7 +47,6 @@ public interface SimplePageItem { public static final int BLTI = 12; public static final int PEEREVAL = 13; public static final int BREAK = 14; - public static final int RESOURCE_FOLDER = 20; public static final int CHECKLIST = 15; public static final int FORUM_SUMMARY = 16; public static final int ANNOUNCEMENTS = 17; diff --git a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/beans/SimplePageBean.java b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/beans/SimplePageBean.java index d07bc51779a8..77d5f5dfa3d1 100644 --- a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/beans/SimplePageBean.java +++ b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/beans/SimplePageBean.java @@ -298,7 +298,6 @@ public enum Status { private Date peerEvalDueDate; private Date peerEvalOpenDate; private boolean peerEvalAllowSelfGrade; - private String folderPath; //variables used for announcements widget private String announcementsHeight; private String announcementsDropdown; @@ -374,14 +373,7 @@ public void setRubricPeerGrade(String rubricPeerGrade) { } rubricPeerGrades.add(rubricPeerGrade); } - public String getFolderPath() { - return folderPath; - } - - public void setFolderPath(String folderPath) { - this.folderPath = folderPath; - } - + // Caches // The following caches are used only during a single display of the page. I believe they @@ -3475,7 +3467,6 @@ public String getReleaseString(SimplePageItem i, Locale locale) { // fall through: groups controlled by LB // for the following items we don't have non-LB items so don't need itemunused case SimplePageItem.TEXT: - case SimplePageItem.RESOURCE_FOLDER: case SimplePageItem.CHECKLIST: case SimplePageItem.PAGE: case SimplePageItem.COMMENTS: @@ -8503,39 +8494,4 @@ public String addForumSummary(){ return status; } - /** - * Method to add Resources folder into Lessons tool - */ - public String folderPickerSubmit(){ - if (!itemOk(itemId)) - return "permission-failed"; - if (!checkCsrf()) - return "permission-failed"; - //Check if user has submitted page without selecting folder? - String defaultPath = contentHostingService.getSiteCollection(getCurrentSiteId()); - folderPath = folderPath.substring(folderPath.indexOf("/", 1)); - if(folderPath == null || folderPath.equals(defaultPath)){ - return "failure"; - } - String dataDirectory = defaultPath + folderPath; - String status = "success"; - if (canEditPage()) { - SimplePageItem item; - // itemid -1 means we're adding a new item to the page, - // specified itemid means we're updating an existing one - if (itemId != null && itemId != -1) { - item = findItem(itemId); - } else { - item = appendItem("", "", SimplePageItem.RESOURCE_FOLDER); - } - item.setAttribute("dataDirectory", dataDirectory); - item.setPrerequisite(this.prerequisite); - setItemGroups(item, selectedGroups); - update(item); - - } else { - status = "cancel"; - } - return status; - } } diff --git a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/FolderPickerProducer.java b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/FolderPickerProducer.java deleted file mode 100644 index 07f9bcc7fe55..000000000000 --- a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/FolderPickerProducer.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.sakaiproject.lessonbuildertool.tool.producers; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.sakaiproject.content.api.ContentHostingService; -import org.sakaiproject.exception.IdUnusedException; -import org.sakaiproject.exception.PermissionException; -import org.sakaiproject.exception.SakaiException; -import org.sakaiproject.exception.TypeException; -import org.sakaiproject.lessonbuildertool.SimplePage; -import org.sakaiproject.lessonbuildertool.SimplePageItem; -import org.sakaiproject.lessonbuildertool.tool.beans.SimplePageBean; -import org.sakaiproject.lessonbuildertool.tool.view.GeneralViewParameters; -import org.sakaiproject.tool.cover.SessionManager; -import uk.org.ponder.localeutil.LocaleGetter; -import uk.org.ponder.messageutil.MessageLocator; -import uk.org.ponder.rsf.components.UIContainer; -import uk.org.ponder.rsf.components.UIBranchContainer; -import uk.org.ponder.rsf.components.UIELBinding; -import uk.org.ponder.rsf.components.UIBoundBoolean; -import uk.org.ponder.rsf.components.UICommand; -import uk.org.ponder.rsf.components.UIForm; -import uk.org.ponder.rsf.components.UIInput; -import uk.org.ponder.rsf.components.UIOutput; -import uk.org.ponder.rsf.components.UIParameter; -import uk.org.ponder.rsf.components.decorators.UIFreeAttributeDecorator; -import uk.org.ponder.rsf.components.decorators.UITooltipDecorator; -import uk.org.ponder.rsf.flow.jsfnav.NavigationCase; -import uk.org.ponder.rsf.flow.jsfnav.NavigationCaseReporter; -import uk.org.ponder.rsf.view.ComponentChecker; -import uk.org.ponder.rsf.view.ViewComponentProducer; -import uk.org.ponder.rsf.viewstate.SimpleViewParameters; -import uk.org.ponder.rsf.viewstate.ViewParameters; -import uk.org.ponder.rsf.viewstate.ViewParamsReporter; - -import javax.faces.component.*; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by neelam on 8/19/2015. - * Displays folders to user to add in Lessons tool - */ -public class FolderPickerProducer implements ViewComponentProducer, NavigationCaseReporter, ViewParamsReporter { - - private SimplePageBean simplePageBean; - public MessageLocator messageLocator; - public LocaleGetter localeGetter; - private ContentHostingService contentHostingService; - public static final String VIEW_ID = "FolderPicker"; - public String getViewID() { - return VIEW_ID; - } - private static Log log = LogFactory.getLog(FolderPickerProducer.class); - - public void fillComponents(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) { - GeneralViewParameters gparams = (GeneralViewParameters) viewparams; - - UIOutput.make(tofill, "html").decorate(new UIFreeAttributeDecorator("lang", localeGetter.get().getLanguage())) - .decorate(new UIFreeAttributeDecorator("xml:lang", localeGetter.get().getLanguage())); - - if (gparams.getSendingPage() != -1) { - // will fail if page not in this site - // security then depends upon making sure that we only deal with this page - try { - simplePageBean.updatePageObject(gparams.getSendingPage()); - } catch (Exception e) { - log.error("FolderPicker permission exception " + e); - return; - } - } - Long itemId = ((GeneralViewParameters) viewparams).getItemId(); - simplePageBean.setItemId(itemId); - - if (simplePageBean.canEditPage()) { - SimplePage page = simplePageBean.getCurrentPage(); - SimplePageItem i = simplePageBean.findItem(itemId); - // if itemid is null, we'll append to current page, so it's ok - if (itemId != null && itemId != -1) { - if (i == null){ - return; - } - // trying to hack on item not on this page - if (i.getPageId() != page.getPageId()){ - return; - } - } - UIOutput.make(tofill, "title-label", messageLocator.getMessage("simplepage.adding-folder")); - UIOutput.make(tofill, "top-folder", simplePageBean.getCurrentSite().getTitle()); - UIOutput.make(tofill, "page-title", simplePageBean.getCurrentPage().getTitle()); - - UIForm form = UIForm.make(tofill, "folder-picker"); - Object sessionToken = SessionManager.getCurrentSession().getAttribute("sakai.csrf.token"); - if (sessionToken != null){ - UIInput.make(form, "csrf", "simplePageBean.csrfToken", sessionToken.toString()); - } - - boolean isPrerequisite = false; - if (itemId != null && itemId != -1) { - isPrerequisite = i.isPrerequisite(); - } - UIOutput.make(form, "prerequisite-block"); - UIBoundBoolean.make(form, "question-prerequisite", "#{simplePageBean.prerequisite}", isPrerequisite); - - //Check the size of collection for the site - String id = simplePageBean.getCurrentSiteId(); - String path = contentHostingService.getSiteCollection(id); - try { - if(contentHostingService.getCollectionSize(path) > 0){ - //get site entity-id - UIInput.make(form, "folder-path", "#{simplePageBean.folderPath}", path); - UIInput.make(form, "add-before", "#{simplePageBean.addBefore}", ((GeneralViewParameters) viewparams).getAddBefore()); - UIInput.make(form, "item-id", "#{simplePageBean.itemId}"); - UIOutput.make(form, "choose-label", messageLocator.getMessage("simplepage.choose.folder")); - UICommand.make(form, "submit", messageLocator.getMessage("simplepage.save_message"), "#{simplePageBean.folderPickerSubmit}").decorate(new UITooltipDecorator(messageLocator.getMessage("simplepage.save_message"))); - //If user has chosen edit option for folder listing - if (itemId != null && itemId > 0) { - form.parameters.add(new UIELBinding("#{simplePageBean.itemId}", gparams.getItemId())); - String dataDirectory = i.getAttribute("dataDirectory"); - if(dataDirectory != null && !dataDirectory.equals("") ){ - String defaultPath = contentHostingService.getSiteCollection(simplePageBean.getCurrentSiteId()); - String[] folderPath = dataDirectory.split(defaultPath); - UIParameter parameter = new UIParameter("edit-folder-path", folderPath[1]); - form.addParameter(parameter); - } - - UICommand.make(form, "delete", messageLocator.getMessage("simplepage.delete"), "#{simplePageBean.deleteItem}").decorate(new UITooltipDecorator(messageLocator.getMessage("simplepage.delete"))); - } - } - //there are no resources in the site to add, display error message - else{ - UIOutput.make(tofill, "error-div"); - UIOutput.make(tofill, "error", messageLocator.getMessage("simplepage.no_resource_folder")); - } - } catch (SakaiException se) { - log.warn("Failed to get size for collection: " + id, se); - } - UICommand.make(form, "cancel", messageLocator.getMessage("simplepage.cancel_message"), "#{simplePageBean.cancel}").decorate(new UITooltipDecorator(messageLocator.getMessage("simplepage.cancel_message"))); - } - else { - UIBranchContainer error = UIBranchContainer.make(tofill, "error"); - UIOutput.make(error, "message", messageLocator.getMessage("simplepage.not_available")); - } - } - - - public void setSimplePageBean(SimplePageBean simplePageBean) { - this.simplePageBean = simplePageBean; - } - - public void setContentHostingService(ContentHostingService contentHostingService) { - this.contentHostingService = contentHostingService; - } - - public ViewParameters getViewParameters() { - return new GeneralViewParameters(); - } - - public List reportNavigationCases() { - List togo = new ArrayList(); - togo.add(new NavigationCase(null, new SimpleViewParameters(ShowPageProducer.VIEW_ID))); - togo.add(new NavigationCase("failure", new SimpleViewParameters(FolderPickerProducer.VIEW_ID))); - togo.add(new NavigationCase("success", new SimpleViewParameters(ShowPageProducer.VIEW_ID))); - togo.add(new NavigationCase("cancel", new SimpleViewParameters(ShowPageProducer.VIEW_ID))); - - return togo; - } - - - -} diff --git a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java index d77a1d008c9a..58812242e4c4 100644 --- a/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java +++ b/lessonbuilder/tool/src/java/org/sakaiproject/lessonbuildertool/tool/producers/ShowPageProducer.java @@ -1226,7 +1226,7 @@ public int compare(SimpleStudentPage o1, SimpleStudentPage o2) { boolean listItem = !(i.getType() == SimplePageItem.TEXT || i.getType() == SimplePageItem.MULTIMEDIA || i.getType() == SimplePageItem.COMMENTS || i.getType() == SimplePageItem.STUDENT_CONTENT - || i.getType() == SimplePageItem.QUESTION || i.getType() == SimplePageItem.PEEREVAL || i.getType() == SimplePageItem.RESOURCE_FOLDER + || i.getType() == SimplePageItem.QUESTION || i.getType() == SimplePageItem.PEEREVAL || i.getType() == SimplePageItem.CHECKLIST || i.getType() == SimplePageItem.FORUM_SUMMARY || i.getType() == SimplePageItem.BREAK || i.getType() == SimplePageItem.ANNOUNCEMENTS ); // (i.getType() == SimplePageItem.PAGE && @@ -1258,7 +1258,6 @@ public int compare(SimpleStudentPage o1, SimpleStudentPage o2) { case SimplePageItem.STUDENT_CONTENT: itemClassName = "studentContentType"; break; case SimplePageItem.QUESTION: itemClassName = "question"; break; case SimplePageItem.BLTI: itemClassName = "bltiType"; break; - case SimplePageItem.RESOURCE_FOLDER: itemClassName = "resourceFolderType"; break; case SimplePageItem.PEEREVAL: itemClassName = "peereval"; break; case SimplePageItem.FORUM_SUMMARY: itemClassName = "forumSummary"; break; case SimplePageItem.ANNOUNCEMENTS: itemClassName = "announcementsType"; break; @@ -2892,40 +2891,6 @@ public int compare(SimpleStudentPage o1, SimpleStudentPage o2) { UIOutput.make(tableRow, "forum-summary-td"); UILink.make(tableRow, "edit-forum-summary", (String) null, ""); } - }else if(i.getType() == SimplePageItem.RESOURCE_FOLDER){ - UIOutput.make(tableRow, "resourceFolderSpan"); - if (canSeeAll) { - String itemGroupString = simplePageBean.getItemGroupString(i, null, true); - String itemGroupTitles = simplePageBean.getItemGroupTitles(itemGroupString, i); - if (itemGroupTitles != null) { - itemGroupTitles = "[" + itemGroupTitles + "]"; - } - - UIOutput.make(tableRow, "resourceFolder-groups-titles", itemGroupTitles); - } - - if(canSeeAll || simplePageBean.isItemAvailable(i)) { - //get directory path from item's attribute - String dataDirectory = i.getAttribute("dataDirectory") != null ? i.getAttribute("dataDirectory") : ""; - String[] folderPath = dataDirectory.split("/"); - String folderName = folderPath[folderPath.length-1]; - if (dataDirectory.endsWith("//")){ - folderName = simplePageBean.getCurrentSite().getTitle(); - } - String html = "

" + folderName + "

"; - UIVerbatim.make(tableRow, "content", html); - } else { - UIComponent unavailableText = UIOutput.make(tableRow, "content", messageLocator.getMessage("simplepage.textItemUnavailable")); - unavailableText.decorate(new UIFreeAttributeDecorator("class", "disabled-text-item")); - } - if (canEditPage) { - UIOutput.make(tableRow, "resourceFolder-td"); - GeneralViewParameters eParams = new GeneralViewParameters(); - eParams.setSendingPage(currentPage.getPageId()); - eParams.setItemId(i.getId()); - eParams.viewID = FolderPickerProducer.VIEW_ID; - UIInternalLink.make(tableRow, "edit-resourceFolder", (String)null, eParams); - } }else if(i.getType() == SimplePageItem.QUESTION) { String itemGroupString = null; String itemGroupTitles = null; @@ -3872,7 +3837,6 @@ private void createToolBar(UIContainer tofill, SimplePage currentPage, boolean i createToolBarLink(EditPageProducer.VIEW_ID, tofill, "add-text", "simplepage.text", currentPage, "simplepage.text.tooltip").setItemId(null); createFilePickerToolBarLink(ResourcePickerProducer.VIEW_ID, tofill, "add-multimedia", "simplepage.multimedia", true, false, currentPage, "simplepage.multimedia.tooltip"); createFilePickerToolBarLink(ResourcePickerProducer.VIEW_ID, tofill, "add-resource", "simplepage.resource", false, false, currentPage, "simplepage.resource.tooltip"); - createToolBarLink(FolderPickerProducer.VIEW_ID, tofill, "add-folder", "simplepage.folder", currentPage, "simplepage.addfolder.tooltip").setItemId(null); UIComponent subpagelink = UIInternalLink.makeURL(tofill, "subpage-link", "#"); subpagelink.decorate(new UITooltipDecorator(messageLocator.getMessage("simplepage.subpage-descrip"))); diff --git a/lessonbuilder/tool/src/resources/messages.properties b/lessonbuilder/tool/src/resources/messages.properties index 6d50dd35fe90..491e7ae1c01f 100644 --- a/lessonbuilder/tool/src/resources/messages.properties +++ b/lessonbuilder/tool/src/resources/messages.properties @@ -725,15 +725,6 @@ simplepage.delete-orphan-pages-desc=Permanently remove all pages that no longer simplepage.filezero=Uploaded file is zero size simplepage.filetoobig=Uploaded file is larger than {} MB - -simplepage.folder=Add Resources Folder -simplepage.addfolder-descrip=Add a Resources folder and its contents. -simplepage.adding-folder=Embed folder listing: -simplepage.addfolder.tooltip=Add a Resources folder and its contents. -simplepage.no_resource_folder=There are no files/folders in resources. -simplepage.choose.folder=Choose a folder to embed, clicking on a file will allow you to preview the contents. -simplepage.active-folder=Selected Folder -simplepage.folder.error=No folder selected , please choose one. simplepage.defaultTitle=Lessons simplepage.indent.level = Indent level diff --git a/lessonbuilder/tool/src/webapp/WEB-INF/applicationContext.xml b/lessonbuilder/tool/src/webapp/WEB-INF/applicationContext.xml index a53304e3e848..42048313ff26 100644 --- a/lessonbuilder/tool/src/webapp/WEB-INF/applicationContext.xml +++ b/lessonbuilder/tool/src/webapp/WEB-INF/applicationContext.xml @@ -171,8 +171,6 @@ simplePageBean.peerEval, simplePageBean.peerEvalDueDate, simplePageBean.peerEvalOpenDate, simplePageBean.peerEvalAllowSelfGrade, -simplePageBean.folderPickerSubmit, -simplePageBean.folderPath, simplePageBean.forumSummaryHeight, simplePageBean.forumSummaryDropDown, simplePageBean.addForumSummary diff --git a/lessonbuilder/tool/src/webapp/WEB-INF/requestContext.xml b/lessonbuilder/tool/src/webapp/WEB-INF/requestContext.xml index 1a69139953d1..80283145f342 100644 --- a/lessonbuilder/tool/src/webapp/WEB-INF/requestContext.xml +++ b/lessonbuilder/tool/src/webapp/WEB-INF/requestContext.xml @@ -176,13 +176,6 @@ - - - - - - - diff --git a/lessonbuilder/tool/src/webapp/css/Simplepagetool.css b/lessonbuilder/tool/src/webapp/css/Simplepagetool.css index 5a08ac14d66a..7f6b64e9f785 100644 --- a/lessonbuilder/tool/src/webapp/css/Simplepagetool.css +++ b/lessonbuilder/tool/src/webapp/css/Simplepagetool.css @@ -1365,6 +1365,7 @@ div[role="dialog"] { } .right-col { + display: inline-block; /* probably no longer needed */ -webkit-column-break-inside: avoid; /* Chrome, Safari, Opera */ page-break-inside: avoid; /* Firefox */ break-inside: avoid; /* standard, IE 10+ */ diff --git a/lessonbuilder/tool/src/webapp/js/folder-picker.js b/lessonbuilder/tool/src/webapp/js/folder-picker.js deleted file mode 100644 index 378f1e9f45e1..000000000000 --- a/lessonbuilder/tool/src/webapp/js/folder-picker.js +++ /dev/null @@ -1,30 +0,0 @@ -$(function() { - var relativePath = $('#folder-path').val(); - if( relativePath !== undefined){ - $('#active-div').show(); - $('.listing').attr('data-directory', relativePath).folderListing({ - onFolderEvent: function(folderCollectionId) { - var folder = folderCollectionId.attr('rel'); - var directory = getDirectoryFromPath(folder); - if (directory==='//') { - directory = '/' + folderCollectionId.text() + '/'; - } - else { - var topFolder = $('#top-folder').text(); - directory = '/' + topFolder + directory; - } - updatePathInput(directory); - }, - onFileEvent: function(file) { - window.open(file); - }, - displayRootDirectory: true - }); - updatePathInput('/' + $('#top-folder').text() + '/'); - - } -}); -function updatePathInput(data){ - $('#active-folder').val(data); - $('#folder-path').val(data); -} diff --git a/lessonbuilder/tool/src/webapp/js/show-page.js b/lessonbuilder/tool/src/webapp/js/show-page.js index ae871d16bb8d..a510445117a5 100644 --- a/lessonbuilder/tool/src/webapp/js/show-page.js +++ b/lessonbuilder/tool/src/webapp/js/show-page.js @@ -2631,9 +2631,7 @@ $(document).ready(function() { $("[aria-describedby='moreDiv'] .ui-dialog-titlebar-close") .click(closeDropdown); - $('.no-highlight').folderListing({ - enableHighlight: false, - }); + return false; }); @@ -3599,4 +3597,4 @@ function fixStatus(here,itemId) { }); return; }; -} +} \ No newline at end of file diff --git a/lessonbuilder/tool/src/webapp/templates/FolderPicker.html b/lessonbuilder/tool/src/webapp/templates/FolderPicker.html deleted file mode 100644 index d6419de4e2b1..000000000000 --- a/lessonbuilder/tool/src/webapp/templates/FolderPicker.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
-
- -
-
-

- - - -

- - -
-
-
- -
- -
-

- - - -

-
-
- - diff --git a/lessonbuilder/tool/src/webapp/templates/ShowPage.html b/lessonbuilder/tool/src/webapp/templates/ShowPage.html index 9549416738af..88be54527940 100644 --- a/lessonbuilder/tool/src/webapp/templates/ShowPage.html +++ b/lessonbuilder/tool/src/webapp/templates/ShowPage.html @@ -56,11 +56,8 @@ - - - @@ -274,9 +271,6 @@

  • -
  • - -

  • @@ -466,12 +460,6 @@

    -
    -
    -
    -
    -
    -

    diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/css/file-tree.css b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/css/file-tree.css deleted file mode 100644 index 4308977b8079..000000000000 --- a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/css/file-tree.css +++ /dev/null @@ -1,285 +0,0 @@ -ul.jqueryFileTree { - font-family: Verdana, sans-serif; - font-size: 13px; - line-height: 18px; - padding: 0px; - margin: 0px; -} - -ul.jqueryFileTree li { - list-style: none; - padding: 0px; - padding-left: 23px; - margin: 0px; - background-position: 3px 3px; - background-repeat: no-repeat; - position: relative; -} -ul.jqueryFileTree li:before{ - content: "\f114"; - font-family: FontAwesome; - float: left; -} - -ul.jqueryFileTree a { - color: #333; - text-decoration: none; - display: block; - padding: 3px; - overflow: hidden; -} - -ul.jqueryFileTree a:hover { - background: #BDF; -} - -/* folder-listing */ -.jqueryFileTree li a .name { - display: block; - float: left; -} -.jqueryFileTree li a .icons { - display: block; - float: left; - overflow: hidden; -} -.jqueryFileTree li a .icons span { - display: block; - float: left; - overflow: hidden; - height: 16px; - width: 16px; - padding: 0; - border: 0px; - margin: 2px; - text-align: center; - line-height: 16px; -} -.jqueryFileTree li a .icons .files { - width: auto; -} - -.jqueryFileTree .copyright { - -} -.jqueryFileTree li a .icons .description { - display: block; - float: left; - height: 16px; - width: 16px; -} - -.jqueryFileTree li a .icons .description:before{ - content: "\f129"; - font-family: FontAwesome; -} - - -.jqueryFileTree .tooltips div { - position: absolute; - top: 28px; - background: #fff; - border: 1px solid #ccc; - padding: 3px; - border-radius: 3px; - z-index: 4; -} - -/* Core Styles */ -.jqueryFileTree li.directory:before{ - content: "\f114"; -} -.jqueryFileTree li.expanded:before { - content: "\f115"; -} -.jqueryFileTree li.file:before { - content: "\f016"; -} -.jqueryFileTree li.wait:before { - content: "\f110"; -} -.jqueryFileTree li.active > a { - font-weight: bold !important; -} -.jqueryFileTree li.active { - background-color: #ffeca3; -} -.jqueryFileTree li.inactive, .jqueryFileTree li.inactive > span { - opacity: 0.5 !important; -} - -/* File Extensions*/ -.jqueryFileTree li.ext_3gp:before { - content: "\f008"; -} -.jqueryFileTree li.ext_afp:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_afpa:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_asp:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_aspx:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_avi:before { - content: "\f008"; -} -.jqueryFileTree li.ext_bat:before { - content: "\f15c"; -} -.jqueryFileTree li.ext_bmp:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_c:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_cfm:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_cgi:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_com { - content: "\f15c"; -} -.jqueryFileTree li.ext_cpp:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_css:before { - content: "\f13c"; -} -.jqueryFileTree li.ext_doc:before { - content: "\f1c2"; -} -.jqueryFileTree li.ext_exe { - content: "\f15c"; -} -.jqueryFileTree li.ext_gif:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_fla:before { - content: "\f0e7"; -} -.jqueryFileTree li.ext_h:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_htm:before { - content: "\f13b"; -} -.jqueryFileTree li.ext_html:before { - content: "\f13b"; -} -.jqueryFileTree li.ext_jar { - content: "\f15c"; -} -.jqueryFileTree li.ext_jpg:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_jpeg:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_js { - content: "\f15c"; -} -.jqueryFileTree li.ext_lasso:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_log:before { - content: "\f0f6"; -} -.jqueryFileTree li.ext_m4p:before { - content: "\f001"; -} -.jqueryFileTree li.ext_mov:before { - content: "\f008"; -} -.jqueryFileTree li.ext_mp3:before { - content: "\f001"; -} -.jqueryFileTree li.ext_mp4:before { - content: "\f008"; -} -.jqueryFileTree li.ext_mpg:before { - content: "\f008"; -} -.jqueryFileTree li.ext_mpeg:before { - content: "\f008"; -} -.jqueryFileTree li.ext_ogg:before { - content: "\f001"; -} -.jqueryFileTree li.ext_pcx:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_pdf:before { - content: "\f1c1"; -} -.jqueryFileTree li.ext_php { - content: "\f15c"; -} -.jqueryFileTree li.ext_png:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_ppt:before { - content: "\f1c4"; -} -.jqueryFileTree li.ext_psd { - content: "\f15c"; -} -.jqueryFileTree li.ext_pl { - content: "\f15c"; -} -.jqueryFileTree li.ext_py { - content: "\f15c"; -} -.jqueryFileTree li.ext_rb { - content: "\f15c"; -} -.jqueryFileTree li.ext_rbx { - content: "\f15c"; -} -.jqueryFileTree li.ext_rhtml { - content: "\f15c"; -} -.jqueryFileTree li.ext_rpm :before { - content: "\f17c"; -} -.jqueryFileTree li.ext_ruby { - content: "\f15c"; -} -.jqueryFileTree li.ext_sql:before { - content: "\f1c0"; -} -.jqueryFileTree li.ext_swf:before { - content: "\f0e7"; -} -.jqueryFileTree li.ext_tif:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_tiff:before { - content: "\f03e"; -} -.jqueryFileTree li.ext_txt:before { - content: "\f0f6"; -} -.jqueryFileTree li.ext_vb:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_wav:before { - content: "\f001"; -} -.jqueryFileTree li.ext_wmv:before { - content: "\f008"; -} -.jqueryFileTree li.ext_xls:before { - content: "\f1c3"; -} -.jqueryFileTree li.ext_xml:before { - content: "\f1c9"; -} -.jqueryFileTree li.ext_zip:before { - content: "\f1c6"; -} diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/directory.png b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/directory.png deleted file mode 100644 index 784e8fa48234..000000000000 Binary files a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/directory.png and /dev/null differ diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/folder_open.png b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/folder_open.png deleted file mode 100644 index 4e3548352fc4..000000000000 Binary files a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/folder_open.png and /dev/null differ diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/spinner.gif b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/spinner.gif deleted file mode 100644 index 85b99d46b991..000000000000 Binary files a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/images/spinner.gif and /dev/null differ diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/file-tree.js b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/file-tree.js deleted file mode 100644 index b6f612eb917e..000000000000 --- a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/file-tree.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * jQuery File Tree Plugin - - * Originally authored by Cory S.N. LaViska - * Edited by Lawrence Okoth-Odida - * A Beautiful Site (http://abeautifulsite.net/) - * Authored 24 March 2008 - * Edited 28 July 2014 - - * USAGE: $('.fileTreeDemo').fileTree(options) - - * settings: root - root folder to display; default = / - * folderEvent - event to trigger expand/collapse; default = click - * expandSpeed - default = 500 (ms); use -1 for no animation - * collapseSpeed - default = 500 (ms); use -1 for no animation - * expandEasing - easing function to use on expand (optional) - * collapseEasing - easing function to use on collapse (optional) - * multiFolder - whether or not to limit the browser to one subfolder at a time - * enableHighlight - whether or not to show the yellow highlight - * loadMessage - Message to display while initial tree loads (can be HTML) - - * TERMS OF USE - This plugin is dual-licensed under the GNU General Public License and the MIT License and - is copyright 2008 A Beautiful Site, LLC. - */ -(function($) { -$.fn.fileTree = function(options) { - // Default settings - var settings = $.extend({ - // general display settings - root: '/', - script: 'fileTree.php', - folderEvent: 'click', - expandSpeed: 500, - collapseSpeed: 500, - expandEasing: null, - collapseEasing: null, - multiFolder: true, - loadMessage: 'Loading...', - openToFolder: false, - enableHighlight: true, - - // configuring the ajax call - ajaxUrl: function(dir) { - return settings.script; - }, - ajaxDataType: 'html', - ajaxType: 'POST', - ajaxData: function(dir) { - return { dir: dir }; - }, - formatResults: function(data) { - return data; - }, - - // events and callbacks - onFolderEvent: function(folder) {}, - onFileEvent: function(file) {}, - afterShowTree: function(element) {}, - afterBindTree: function(element) {}, - }, options); - - // backwards compatibility - if (arguments.length > 1) { - settings.onFileEvent = arguments[1] || settings.onFileEvent; - } - - var showTree = function(element, dir) { - var $element = $(element); - - $element.addClass('wait'); - $(".jqueryFileTree.start").remove(); - - $.ajax({ - url: settings.ajaxUrl(dir), - dataType: settings.ajaxDataType, - type: settings.ajaxType, - data: settings.ajaxData(dir), - cache:false, - success: function(json) { - var data = settings.formatResults(json); - - $element.find('.start').html(''); - $element.removeClass('wait').append(data); - - if (settings.root == dir) { - $element.find('ul:hidden').show(); - } else { - $element.find('ul:hidden').slideDown({ duration: settings.expandSpeed, easing: settings.expandEasing }); - } - - $element.trigger('fileTree_showTree'); - settings.afterShowTree(element); - - bindTree(element); - }, - error: function() { - $element.removeClass('wait'); - console.log('Folder "' + dir + '" not found'); - } - }); - }; - - var bindTree = function(element) { - var $anchors = $(element).find('li a'); - - $anchors.on(settings.folderEvent, function() { - var $this = $(this); - var $parent = $this.parent(); - //Check if yellow highlight is needed for selection - if(settings.enableHighlight){ - // reset 'active' element and set it to current directory/file - $parent.closest('div > .jqueryFileTree').find('.active').removeClass('active'); - $parent.addClass('active'); - } - if ($parent.hasClass('directory')) { - if ($parent.hasClass('collapsed')) { - // expand - if (!settings.multiFolder) { - $parent.parent().find('ul').slideUp({ - duration: settings.collapseSpeed, - easing: settings.collapseEasing - }); - $parent.parent().find('li.directory').removeClass('expanded').addClass('collapsed'); - } - $parent.find('ul').remove(); // cleanup - showTree($parent, encodeURI($this.attr('rel').match( /.*\// ))); - $parent.removeClass('collapsed').addClass('expanded'); - } else { - // collapse - $parent.find('ul').slideUp({ duration: settings.collapseSpeed, easing: settings.collapseEasing }); - $parent.removeClass('expanded').addClass('collapsed'); - } - - settings.onFolderEvent($this); - } else { - settings.onFileEvent($this.attr('rel')); - } - - return false; - }); - - // prevent a from triggering the # on non-click events - if (settings.folderEvent.toLowerCase() != 'click') { - $anchors.on('click', function() { - return false; - }); - } - - $anchors.trigger('fileTree_bindTree'); - - settings.afterBindTree(element); - }; - - var openToFolder = function($tree, dir) { - // make array of remaining folders to enter - var directoryList = dir.replace(settings.root, ''); - directoryList = directoryList.split('/'); - directoryList = directoryList.filter(function(e) { return e; }); - - // note current path (this string will be expanded) - var currentPath = settings.root; - var i = 0; - - // when a new folder has been inserted to the tree, find the right link and click it - $tree.on('DOMNodeInserted', 'ul', function() { - if (i >= directoryList.length) { - return; - } - - var nextElem = directoryList[i]; - currentPath += nextElem + '/'; - - var a = $(this).find('[rel="'+ currentPath +'"], [rel="'+ currentPath +'/"]').first(); - - if (a.length > 0) { - a.on('fileTree_bindTree', function() { - $(this).click(); - }); - } - - i++; - }); - }; - - return this.each(function() { - var $this = $(this); - - // loading message - $this.html('
    • ' + settings.loadMessage + '
    '); - - // get the initial file list - showTree($this, encodeURI(settings.root)); - - // open to the correct folder - if (settings.openToFolder) { - openToFolder($this, settings.openToFolder); - } - }); -}; -})(jQuery); diff --git a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/folder-listing.js b/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/folder-listing.js deleted file mode 100644 index 835b8bb7a534..000000000000 --- a/reference/library/src/webapp/editor/ckextraplugins/folder-listing/js/folder-listing.js +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Title: folderListing (Oxford WebLearn integration of jQuery fileTree) - * Description: Provides a listing of folders in the Resources section of - Weblearn given a relative path (e.g. /groups/...) - * Author: Lawrence Okoth-Odida - * Version: 0.1 - * Date: 30/07/2014 - - * BASIC USAGE - - * ADVANCED USAGE - - */ - -(function($) { -$.fn.folderListing = function(options) { - // Default settings - var settings = $.extend({ - openToFolder: false, - enableHighlight: true, - displayRootDirectory: false, - onFolderEvent: function(folder) {}, - onFileEvent: function(file) { - window.open(file); - }, - afterShowTree: function(element) {}, - afterBindTree: function(element) {} - }, options); - - var urlPrefix = '/direct/content/resources/'; - - var getHtmlResults = function(json, $div, root) { - var html = $('