Skip to content
Snippets Groups Projects
Commit 2742510f authored by srosse's avatar srosse
Browse files

CL-526: change implementation of logo

parent 60bbacdc
No related branches found
No related tags found
No related merge requests found
Showing
with 77 additions and 126 deletions
......@@ -31,7 +31,6 @@ import org.apache.commons.lang.StringEscapeUtils;
import org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.panel.StackedPanel;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
......@@ -65,17 +64,10 @@ public class DisplayPortraitController extends BasicController implements Generi
private final String mapperPath;
private final UserAvatarMapper mapper;
private final OLATResourceable listenerOres;
private final StackedPanel mainPanel;
private final boolean useLarge;
private final boolean isAnonymous;
private final Display displayImage;
public enum Display {
portrait,
logo,
none
}
private final boolean displayPortraitImage;
/**
* most common used constructor<br />
......@@ -92,7 +84,7 @@ public class DisplayPortraitController extends BasicController implements Generi
*/
public DisplayPortraitController(UserRequest ureq, WindowControl wControl, Identity portraitIdent,
boolean useLarge, boolean canLinkToHomePage) {
this(ureq, wControl, portraitIdent, useLarge, canLinkToHomePage, false, Display.portrait);
this(ureq, wControl, portraitIdent, useLarge, canLinkToHomePage, false, true);
}
/**
......@@ -116,31 +108,6 @@ public class DisplayPortraitController extends BasicController implements Generi
*/
public DisplayPortraitController(UserRequest ureq, WindowControl wControl, Identity portraitIdent,
boolean useLarge, boolean canLinkToHomePage, boolean displayUserFullName, boolean displayPortraitImage) {
this(ureq, wControl, portraitIdent, useLarge, canLinkToHomePage, displayUserFullName, displayPortraitImage ? Display.portrait : Display.none);
}
/**
* constructor with more config options<br />
* use this if you want to display the full name of the user or the logo (additionally or only)
*
* @param ureq
* @param wControl
* @param portraitIdent
* the identity to display
* @param useLarge
* if set to true, the portrait-image is displayed as "big"
* @param canLinkToHomePage
* if set to true, the portrait is linked to the users homepage
* @param displayUserFullName
* if set to true, the users full name ("firstname lastname") is
* displayed as well
* @param displayImage
* if set to none, the portrait image will not be displayed, set to portrait, show the protrait
* set to logo, show the logo.
*/
public DisplayPortraitController(UserRequest ureq, WindowControl wControl, Identity portraitIdent,
boolean useLarge, boolean canLinkToHomePage, boolean displayUserFullName, Display displayImage) {
super(ureq, wControl);
myContent = createVelocityContainer("displayportrait");
myContent.contextPut("canLinkToHomePage", canLinkToHomePage ? Boolean.TRUE : Boolean.FALSE);
......@@ -148,10 +115,10 @@ public class DisplayPortraitController extends BasicController implements Generi
this.useLarge = useLarge;
this.portraitIdent = portraitIdent;
this.displayImage = displayImage;
this.displayPortraitImage = displayPortraitImage;
this.isAnonymous = ureq.getUserSession().getRoles().isGuestOnly();
mapper = new UserAvatarMapper(useLarge, displayImage);
mapper = new UserAvatarMapper(useLarge);
mapperPath = registerMapper(ureq, mapper);
myContent.contextPut("identityKey", portraitIdent.getKey().toString());
......@@ -160,7 +127,7 @@ public class DisplayPortraitController extends BasicController implements Generi
myContent.contextPut("fullName", fullName);
String altText = translate("title.homepage") + ": " + fullName;
myContent.contextPut("altText", StringEscapeUtils.escapeHtml(altText));
mainPanel = putInitialPanel(myContent);
putInitialPanel(myContent);
loadPortrait();
......@@ -175,49 +142,38 @@ public class DisplayPortraitController extends BasicController implements Generi
private void loadPortrait() {
File image = null;
if(displayImage != Display.none) {
if(displayImage == Display.logo) {
if (useLarge) {
image = DisplayPortraitManager.getInstance().getBigLogo(portraitIdent.getName());
myContent.contextPut("portraitCssClass", DisplayPortraitManager.LOGO_BIG_CSS_CLASS);
} else {
image = DisplayPortraitManager.getInstance().getSmallLogo(portraitIdent.getName());
myContent.contextPut("portraitCssClass", DisplayPortraitManager.LOGO_SMALL_CSS_CLASS);
}
mainPanel.setVisible(image != null);
} else if(displayImage == Display.portrait) {
GenderPropertyHandler genderHander = (GenderPropertyHandler) UserManager.getInstance().getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER);
String gender = "-"; // use as default
if (genderHander != null) {
gender = genderHander.getInternalValue(portraitIdent.getUser());
if(displayPortraitImage) {
GenderPropertyHandler genderHander = (GenderPropertyHandler) UserManager.getInstance().getUserPropertiesConfig().getPropertyHandler(UserConstants.GENDER);
String gender = "-"; // use as default
if (genderHander != null) {
gender = genderHander.getInternalValue(portraitIdent.getUser());
}
if (useLarge) {
image = DisplayPortraitManager.getInstance().getBigPortrait(portraitIdent.getName());
if (image != null) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.AVATAR_BIG_CSS_CLASS);
} else if (isAnonymous) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.ANONYMOUS_BIG_CSS_CLASS);
} else if (gender.equals("-")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_BIG_CSS_CLASS);
} else if (gender.equals("male")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_BIG_CSS_CLASS);
} else if (gender.equals("female")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_BIG_CSS_CLASS);
}
if (useLarge) {
image = DisplayPortraitManager.getInstance().getBigPortrait(portraitIdent.getName());
if (image != null) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.AVATAR_BIG_CSS_CLASS);
} else if (isAnonymous) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.ANONYMOUS_BIG_CSS_CLASS);
} else if (gender.equals("-")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_BIG_CSS_CLASS);
} else if (gender.equals("male")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_BIG_CSS_CLASS);
} else if (gender.equals("female")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_BIG_CSS_CLASS);
}
} else {
image = DisplayPortraitManager.getInstance().getSmallPortrait(portraitIdent.getName());
if (image != null) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.AVATAR_SMALL_CSS_CLASS);
} else if (isAnonymous) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.ANONYMOUS_SMALL_CSS_CLASS);
} else if (gender.equals("-")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_SMALL_CSS_CLASS);
} else if (gender.equals("male")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_SMALL_CSS_CLASS);
} else if (gender.equals("female")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_SMALL_CSS_CLASS);
}
} else {
image = DisplayPortraitManager.getInstance().getSmallPortrait(portraitIdent.getName());
if (image != null) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.AVATAR_SMALL_CSS_CLASS);
} else if (isAnonymous) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.ANONYMOUS_SMALL_CSS_CLASS);
} else if (gender.equals("-")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_SMALL_CSS_CLASS);
} else if (gender.equals("male")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_MALE_SMALL_CSS_CLASS);
} else if (gender.equals("female")) {
myContent.contextPut("portraitCssClass", DisplayPortraitManager.DUMMY_FEMALE_SMALL_CSS_CLASS);
}
}
......
......@@ -72,9 +72,15 @@ public class DisplayPortraitManager extends BasicManager implements UserDataDele
public static final String DUMMY_MALE_BIG_CSS_CLASS = "o_portrait_dummy_male_big";
public static final String DUMMY_MALE_SMALL_CSS_CLASS = "o_portrait_dummy_male_small";
public static final int HEIGHT_BIG = 100; // 4-8 kbytes (jpeg)
public static final int HEIGHT_SMALL = 30; // 2-4
// If you change the following widths, don't forget to change them in basemod.scss as well.
public static final int WIDTH_PORTRAIT_BIG = 100; // 4-8 kbytes (jpeg)
public static final int WIDTH_PORTRAIT_SMALL = 30; // 2-4
public static final int WIDTH_PORTRAIT_BIG = HEIGHT_BIG; // 4-8 kbytes (jpeg)
public static final int WIDTH_PORTRAIT_SMALL = HEIGHT_SMALL; // 2-4
public static final int WIDTH_LOGO_BIG = HEIGHT_BIG * 4; // 4-8 kbytes (jpeg)
public static final int WIDTH_LOGO_SMALL = HEIGHT_SMALL * 4; // 2-4
/**
* [spring]
......@@ -177,14 +183,17 @@ public class DisplayPortraitManager extends BasicManager implements UserDataDele
}
public void setPortrait(File file, String filename, String username) {
setImage(file, filename, username, PORTRAIT_PREFIX_FILENAME, PORTRAIT_BIG_FILENAME, PORTRAIT_SMALL_FILENAME);
setImage(file, filename, username, PORTRAIT_PREFIX_FILENAME, PORTRAIT_BIG_FILENAME, PORTRAIT_SMALL_FILENAME,
WIDTH_PORTRAIT_BIG, WIDTH_PORTRAIT_SMALL);
}
public void setLogo(File file, String filename, String username) {
setImage(file, filename, username, LOGO_PREFIX_FILENAME, LOGO_BIG_FILENAME, LOGO_SMALL_FILENAME);
setImage(file, filename, username, LOGO_PREFIX_FILENAME, LOGO_BIG_FILENAME, LOGO_SMALL_FILENAME,
WIDTH_LOGO_BIG, WIDTH_LOGO_SMALL);
}
private void setImage(File file, String filename, String username, String prefix, String largeImagePrefix, String smallImagePrefix) {
private void setImage(File file, String filename, String username, String prefix, String largeImagePrefix, String smallImagePrefix,
int maxBigWidth, int maxSmallWidth) {
File directory = getPortraitDir(username);
if(directory != null) {
for(File currentImage:directory.listFiles()) {
......@@ -208,9 +217,9 @@ public class DisplayPortraitManager extends BasicManager implements UserDataDele
File bigFile = new File(directory, largeImagePrefix + "." + extension);
File smallFile = new File(directory, smallImagePrefix + "." + extension);
ImageService imageHelper = CoreSpringFactory.getImpl(ImageService.class);
Size size = imageHelper.scaleImage(file, extension, bigFile, WIDTH_PORTRAIT_BIG, WIDTH_PORTRAIT_BIG, false);
Size size = imageHelper.scaleImage(file, extension, bigFile, maxBigWidth, HEIGHT_BIG , false);
if(size != null){
size = imageHelper.scaleImage(file, extension, smallFile, WIDTH_PORTRAIT_SMALL, WIDTH_PORTRAIT_SMALL, false);
size = imageHelper.scaleImage(file, extension, smallFile, maxSmallWidth, HEIGHT_SMALL, false);
}
}
......
......@@ -25,6 +25,7 @@
package org.olat.user;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
......@@ -32,6 +33,7 @@ import java.util.List;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.image.ImageComponent;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
......@@ -49,7 +51,6 @@ import org.olat.instantMessaging.InstantMessagingModule;
import org.olat.instantMessaging.InstantMessagingService;
import org.olat.instantMessaging.OpenInstantMessageEvent;
import org.olat.instantMessaging.model.Buddy;
import org.olat.user.DisplayPortraitController.Display;
import org.olat.user.propertyhandlers.UserPropertyHandler;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -123,9 +124,11 @@ public class HomePageDisplayController extends BasicController {
mainVC.put("image", dpc.getInitialComponent());
if(UserModule.isLogoByProfileEnabled()) {
Controller dlc = new DisplayPortraitController(ureq, getWindowControl(), homeIdentity, true, false, false, Display.logo);
listenTo(dlc); // auto dispose
mainVC.put("logo", dlc.getInitialComponent());
File logo = DisplayPortraitManager.getInstance().getBigLogo(homeIdentity.getName());
ImageComponent logoCmp = new ImageComponent(ureq.getUserSession(), "logo");
logoCmp.setMedia(logo);
logoCmp.setMaxWithAndHeightToFitWithin(300, 66);
mainVC.put("logo", logoCmp);
}
putInitialPanel(mainVC);
......
......@@ -25,7 +25,6 @@ import org.olat.core.CoreSpringFactory;
import org.olat.core.dispatcher.mapper.Mapper;
import org.olat.core.gui.media.MediaResource;
import org.olat.core.id.Identity;
import org.olat.user.DisplayPortraitController.Display;
/**
*
......@@ -40,14 +39,8 @@ public class UserAvatarMapper implements Mapper {
private final UserManager userManager;
private final DisplayPortraitManager portraitManager;
private final boolean useLarge;
private final Display displayImage;
public UserAvatarMapper(boolean useLargePortrait) {
this(useLargePortrait, Display.portrait);
}
public UserAvatarMapper(boolean useLargePortrait, Display displayImage) {
this.displayImage = displayImage;
useLarge = useLargePortrait;
portraitManager = DisplayPortraitManager.getInstance();
userManager = CoreSpringFactory.getImpl(UserManager.class);
......@@ -65,19 +58,11 @@ public class UserAvatarMapper implements Mapper {
String idKey = relPath.substring(0, endKeyIndex);
Long key = Long.parseLong(idKey);
String username = userManager.getUsername(key);
if(displayImage == Display.portrait) {
if (useLarge) {
return portraitManager.getBigPortraitResource(username);
} else {
return portraitManager.getSmallPortraitResource(username);
}
} else if(displayImage == Display.logo) {
if (useLarge) {
return portraitManager.getBigLogoResource(username);
} else {
return portraitManager.getSmallLogoResource(username);
}
}
if (useLarge) {
return portraitManager.getBigPortraitResource(username);
} else {
return portraitManager.getSmallPortraitResource(username);
}
}
}
return null;
......
......@@ -29,6 +29,5 @@
#end
</div>
#end
</div>
\ No newline at end of file
......@@ -50,7 +50,7 @@ doCompile () {
UPDATE=$UPDATECMD
if [ $1 = "." ];
then
TARGET="openolat"
TARGET="light"
if [[ "--watch" == $UPDATECMD && ! -z $THEMES ]]; then UPDATE="--update"; fi
fi
echo "Compiling SASS: $TARGET $STYLE"
......
......@@ -5,7 +5,7 @@
.o_bcard_logo {
position: absolute;
top:19px;
right:19px;
right:29px;
}
.o_bcard_title_with_logo {
......@@ -23,20 +23,22 @@
}
.o_visitingcard .o_portrait_avatar,
.o_visitingcard .o_portrait_logo,
.o_visitingcard .o_portrait_dummy,
.o_visitingcard .o_portrait_dummy_female_big,
.o_visitingcard .o_portrait_dummy_male_big,
.o_visitingcard .o_portrait_anonymous { width: 66px; height: 66px; margin-right: 10px;}
.o_visitingcard_logo img { max-width:400px; max-height: 66px; margin-right: 10px;}
@media (max-width: $screen-xs-max) {
.o_visitingcard .o_portrait_avatar,
.o_visitingcard .o_portrait_logo,
.o_visitingcard .o_portrait_dummy,
.o_visitingcard .o_portrait_dummy_female_big,
.o_visitingcard .o_portrait_dummy_male_big,
.o_visitingcard .o_portrait_anonymous { width: 50px; height: 50px; margin: 5px 5px 0 0;}
.o_visitingcard_logo img { max-width:300px; max-height: 50px; margin: 5px 5px 0 0;}
.o_bcard_title_with_logo {
padding-right: 70px;
}
......
......@@ -255,7 +255,6 @@ ul.o_dropdown {
.o_portrait_dummy,
.o_portrait_dummy_female_big,
.o_portrait_dummy_male_big,
.o_portrait_logo,
.o_portrait_anonymous {width: 100px; height: 100px;}
.o_portrait_dummy {background-image: url('#{$o-images-path}portrait/dummy.png');}
.o_portrait_dummy_female_big {background-image: url('#{$o-images-path}portrait/dummy_female_big.png');}
......@@ -266,14 +265,12 @@ ul.o_dropdown {
.o_portrait_dummy_small,
.o_portrait_dummy_female_small,
.o_portrait_dummy_male_small,
.o_portrait_logo_small,
.o_portrait_anonymous_small {width: 30px; height: 30px;}
.o_portrait_dummy_small {background-image: url('#{$o-images-path}portrait/dummy_small.png');}
.o_portrait_dummy_female_small {background-image: url('#{$o-images-path}portrait/dummy_female_small.png');}
.o_portrait_dummy_male_small {background-image: url('#{$o-images-path}portrait/dummy_male_small.png');}
.o_portrait_anonymous_small {background-image: url('#{$o-images-path}portrait/anonymous_small.png'); }
/* Date component, used in info course element, blog etc */
.o_datecomp {
position: relative;
......
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment