diff --git a/src/main/java/org/olat/home/HomeMainController.java b/src/main/java/org/olat/home/HomeMainController.java index 0d7d4599cc790595fd299481d1857c0db4d6b0b5..9101bda2468c73135aa2a52658d7542e1dec8734 100644 --- a/src/main/java/org/olat/home/HomeMainController.java +++ b/src/main/java/org/olat/home/HomeMainController.java @@ -86,7 +86,7 @@ public class HomeMainController extends MainLayoutBasicController implements Act } } - if(navKey.equals(currentNavKey) && currentCtr != null) { + if(navKey.equals(currentNavKey) && currentCtr instanceof ReusableHomeController) { if (currentCtr instanceof Activateable2) { ((Activateable2) currentCtr).activate(ureq, entries, entry.getTransientState()); } diff --git a/src/main/java/org/olat/home/ReusableHomeController.java b/src/main/java/org/olat/home/ReusableHomeController.java new file mode 100644 index 0000000000000000000000000000000000000000..8223b66bd9e2094d259b117fd984291876f36d43 --- /dev/null +++ b/src/main/java/org/olat/home/ReusableHomeController.java @@ -0,0 +1,34 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.home; + +import org.olat.core.gui.control.Controller; + +/** + * This is a marker interface for personal tools which main controller + * are reusable. + * + * Initial date: 27.06.2016<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public interface ReusableHomeController extends Controller { + +} diff --git a/src/main/java/org/olat/modules/portfolio/ui/PortfolioPersonalToolController.java b/src/main/java/org/olat/modules/portfolio/ui/PortfolioPersonalToolController.java index a4e2785a44d771bcd533d0fa5867b043c35bd0ff..f77ba9ba2d4c1a22f7657782b968efa715611561 100644 --- a/src/main/java/org/olat/modules/portfolio/ui/PortfolioPersonalToolController.java +++ b/src/main/java/org/olat/modules/portfolio/ui/PortfolioPersonalToolController.java @@ -32,6 +32,7 @@ import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.util.resource.OresHelper; +import org.olat.home.ReusableHomeController; /** * @@ -39,7 +40,7 @@ import org.olat.core.util.resource.OresHelper; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class PortfolioPersonalToolController extends BasicController implements Activateable2 { +public class PortfolioPersonalToolController extends BasicController implements Activateable2, ReusableHomeController { private final TooledStackedPanel stackPanel; private final PortfolioHomeController overviewCtrl; diff --git a/src/main/java/org/olat/portfolio/ui/artefacts/collect/CmdAddToEPortfolioImpl.java b/src/main/java/org/olat/portfolio/ui/artefacts/collect/CmdAddToEPortfolioImpl.java index f0162f3afd23af3076856219e47c4ce2db942e1c..2196717e8488a96a485ac67456f4a53e75863600 100644 --- a/src/main/java/org/olat/portfolio/ui/artefacts/collect/CmdAddToEPortfolioImpl.java +++ b/src/main/java/org/olat/portfolio/ui/artefacts/collect/CmdAddToEPortfolioImpl.java @@ -32,8 +32,15 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.translator.Translator; +import org.olat.core.util.FileUtils; import org.olat.core.util.StringHelper; import org.olat.core.util.vfs.VFSItem; +import org.olat.modules.portfolio.MediaHandler; +import org.olat.modules.portfolio.PortfolioService; +import org.olat.modules.portfolio.PortfolioV2Module; +import org.olat.modules.portfolio.handler.FileHandler; +import org.olat.modules.portfolio.handler.ImageHandler; +import org.olat.modules.portfolio.ui.wizard.CollectArtefactController; import org.olat.portfolio.EPArtefactHandler; import org.olat.portfolio.PortfolioModule; import org.olat.portfolio.model.artefacts.AbstractArtefact; @@ -54,11 +61,14 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE private int status; private VFSItem currentItem; private PortfolioModule portfolioModule; + private PortfolioV2Module portfolioV2Module; + private Controller collectStepsCtrl; public CmdAddToEPortfolioImpl(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); - portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule"); + portfolioModule = CoreSpringFactory.getImpl(PortfolioModule.class); + portfolioV2Module = CoreSpringFactory.getImpl(PortfolioV2Module.class); } /** @@ -84,14 +94,36 @@ public class CmdAddToEPortfolioImpl extends BasicController implements CmdAddToE currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos)); status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem); } - if (status == FolderCommandStatus.STATUS_FAILED) { return null; } - - EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE); - AbstractArtefact artefact = artHandler.createArtefact(); - artHandler.prefillArtefactAccordingToSource(artefact, currentItem); - artefact.setAuthor(getIdentity()); + if (status == FolderCommandStatus.STATUS_FAILED) { + return null; + } + + if(portfolioV2Module.isEnabled()) { + PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class); + + MediaHandler handler = null; + + String extension = FileUtils.getFileSuffix(currentItem.getName()); + if(StringHelper.containsNonWhitespace(extension)) { + if("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) + || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) { + handler = portfolioService.getMediaHandler(ImageHandler.IMAGE_TYPE); + } + //TODO video + } + + if(handler == null) { + handler = portfolioService.getMediaHandler(FileHandler.FILE_TYPE); + } + collectStepsCtrl = new CollectArtefactController(ureq, wControl, currentItem, handler, ""); + } else { + EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE); + AbstractArtefact artefact = artHandler.createArtefact(); + artHandler.prefillArtefactAccordingToSource(artefact, currentItem); + artefact.setAuthor(getIdentity()); - collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer()); + collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer()); + } return collectStepsCtrl; }