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

Merge with 9c065869788812849724feb453ea84ef9371a098

parents a41d2a52 a14f8308
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.olat.core.commons.chiefcontrollers.BaseChiefController;
import org.olat.core.defaults.dispatcher.StaticMediaDispatcher;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.helpers.Settings;
/**
......@@ -496,8 +498,8 @@ public class Formatter {
// Pattern to find URL's in text
private static final Pattern urlPattern = Pattern.compile("((http[s]*://|www\\.)[-A-Za-z0-9+&@#/%?=~_|!:,\\.;]+[-A-Za-z0-9+&@#/%=~_|]*)");
private static final Pattern urlPattern = Pattern.compile("((mailto\\:|(news|(ht|f)tp(s?))\\://|www\\.)[-A-Za-z0-9+&@#/%?=~_|!:,\\.;]+[-A-Za-z0-9+&@#/%=~_|]*)");
/**
* Search in given text fragment for URL's and surround them with clickable
* HTML link objects.
......@@ -518,21 +520,27 @@ public class Formatter {
// The URL is in group1, the other groups are ignored
String url = matcher.group(1);
// Fix URL's without protocol, assume http
if (!url.startsWith("http")) {
if (url.startsWith("www")) {
url = "http://" + url;
}
// Fix URL's at end of a sentence
if (url.endsWith(",") || url.endsWith(".")) {
if (url.endsWith(",") || url.endsWith(".") || url.endsWith(":")) {
url = url.substring(0, url.length()-1);
pos--;
}
sb.append("<a href=\"");
sb.append(url);
sb.append("\"");
if (url.startsWith("mailto")) {
sb.append(" target=\"_blank\" class=\"b_link_mailto\"");
}
// OpenOLAT URL's are opened in same window, all other URL's in separate window
if (!url.startsWith(Settings.getServerContextPathURI())) {
else if (!url.startsWith(Settings.getServerContextPathURI())) {
sb.append(" target=\"_blank\" class=\"b_link_extern\"");
}
else {
sb.append(" class=\"b_link_forward\"");
}
sb.append(">");
sb.append(url);
sb.append("</a>");
......@@ -543,6 +551,63 @@ public class Formatter {
return sb.toString();
}
/* emoticon patterns */
private static final Pattern angelPattern = Pattern.compile("(O\\:-*(\\)|3))");
private static final Pattern angryPattern = Pattern.compile("(\\:-*(\\|\\||@))");
private static final Pattern confusedPattern = Pattern.compile("(%-*\\))");
private static final Pattern coolPattern = Pattern.compile("(8-*\\))");
private static final Pattern grinPattern = Pattern.compile("(;-*\\))");
private static final Pattern kissPattern = Pattern.compile("(\\:(\\^)*\\*)");
private static final Pattern ohohPattern = Pattern.compile("(\\:-*O)");
private static final Pattern sadPattern = Pattern.compile("(\\:-*\\()");
private static final Pattern smilePattern = Pattern.compile("(\\:-*\\))");
private static final Pattern tonguePattern = Pattern.compile("(\\:-*P)");
private static final Pattern upPattern = Pattern.compile("(\\+(\\s|$))");
private static final Pattern downPattern = Pattern.compile("(-(\\s|$))");
private static final StringOutput emptyGifUrl = new StringOutput();
static {
StaticMediaDispatcher.renderStaticURI(emptyGifUrl, "images/transparent.gif");
}
/**
* Search in textFragment for emoticons such as :-) :-( etc and replace them
* with image tags that render a nice icon.
*
* @param textFragment
* @return replaced text
*/
public static String formatEmoticonsAsImages(String textFragment) {
Matcher matcher;
matcher = confusedPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_confused' />");
matcher = coolPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_cool' />");
matcher = angryPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_angry' />");
matcher = grinPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_grin' />");
matcher = kissPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_kiss' />");
matcher = ohohPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_ohoh' />");
matcher = smilePattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_angel' />");
matcher = angelPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_smile' />");
matcher = sadPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_sad' />");
matcher = tonguePattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_tongue' />");
matcher = upPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_up' />");
matcher = downPattern.matcher(textFragment);
textFragment= matcher.replaceAll("<img src='" + emptyGifUrl + "' class='b_emoticons_down' />");
return textFragment;
}
/**
* Round a double value to a double value with given number of
* figures after comma
......@@ -585,4 +650,3 @@ public class Formatter {
}
}
\ No newline at end of file
......@@ -49,6 +49,7 @@ import org.olat.core.id.Identity;
import org.olat.core.id.Roles;
import org.olat.core.id.User;
import org.olat.core.id.UserConstants;
import org.olat.core.util.StringHelper;
import org.olat.core.util.WebappHelper;
import org.olat.course.nodes.BasicLTICourseNode;
import org.olat.course.run.environment.CourseEnvironment;
......@@ -202,6 +203,14 @@ public class LTIRunController extends BasicController {
setProperty(props, "resource_link_title", courseNode.getShortTitle());
setProperty(props, "resource_link_description", courseNode.getLongTitle());
setProperty(props, "user_id", u.getKey() + "");
// Use the shibboleth ID as person source identificator
String personSourceId = (String)ureq.getUserSession().getEntry("shibuid");
if (!StringHelper.containsNonWhitespace(personSourceId)) {
// fallback to the serverDomainName:identityId
personSourceId = Settings.getServerconfig("server_fqdn") + ":" + ident.getKey();
}
setProperty(props, "lis_person_sourcedid", personSourceId);
setProperty(props, "launch_presentation_locale", loc.toString());
setProperty(props, "launch_presentation_document_target", "iframe");
......
......@@ -89,7 +89,7 @@ table.header.leave.waiting=Verlassen
table.header.login=Benutzername
table.header.group.full=Voll belegt
table.header.mark=Favorit
table.header.online=On
table.header.online=Chat
table.header.type=Typ
table.header.resources=Kurse
table.header.role=Rolle
......
......@@ -143,6 +143,7 @@ table.header.leave.waiting=Leave
table.header.login=User name
table.header.mail=E-mail
table.header.mark=Bookmark
table.header.online=Chat
table.header.participants=Participant
table.header.participantsCount=Assigned
table.header.remove=Remove
......
......@@ -31,8 +31,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
......@@ -88,7 +86,6 @@ public class ChatController extends BasicController implements GenericEventListe
private List<String> allChats;
private final Formatter formatter;
private static final Pattern mailPattern = Pattern.compile("((mailto\\:|(news|(ht|f)tp(s?))\\://){1}\\S+)");
private final boolean vip;
private final OLATResourceable ores;
......@@ -362,15 +359,8 @@ public class ChatController extends BasicController implements GenericEventListe
}
private String prepareMsgBody(String body) {
List<String> done = new ArrayList<String>(3);
Matcher m = mailPattern.matcher(body);
while (m.find()) {
String l = m.group();
if (!done.contains(l)) {
body = body.replaceFirst(l, "<a href=\""+l+"\" target=\"_blank\">"+l+"</a>");
}
done.add(l);
}
body = Formatter.formatURLsAsLinks(body);
body = Formatter.formatEmoticonsAsImages(body);
return body;
}
......
......@@ -247,24 +247,26 @@ div.b_form_auto_completer_item.b_error_icon { color: $nokcolor; font-style: ital
/* ---------- smilies / emoticons in tinyMCE ------------------------ */
/* i know, these are icons... but they must be in content.css, 'cause tinyMCE needs 'em... */
img.b_emoticons_angel {background : url(../../openolat/images/emoticons/smiley-angel.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_angry {background : url(../../openolat/images/emoticons/smiley-mad.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_blushing {background : url(../../openolat/images/emoticons/smiley-red.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_confused {background : url(../../openolat/images/emoticons/smiley-confuse.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_cool {background : url(../../openolat/images/emoticons/smiley-cool.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_cry {background : url(../../openolat/images/emoticons/smiley-cry.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_devil {background : url(../../openolat/images/emoticons/smiley-evil.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_grin {background : url(../../openolat/images/emoticons/smiley-grin.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_kiss {background : url(../../openolat/images/emoticons/smiley-kiss.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_ohoh {background : url(../../openolat/images/emoticons/smiley-eek.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_sad {background : url(../../openolat/images/emoticons/smiley-sad.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_sick {background : url(../../openolat/images/emoticons/smiley-sad-blue.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_smile {background : url(../../openolat/images/emoticons/smiley.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_tongue {background : url(../../openolat/images/emoticons/smiley-razz.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_ugly {background : url(../../openolat/images/emoticons/smiley-money.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_weird {background : url(../../openolat/images/emoticons/smiley-nerd.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_wink {background : url(../../openolat/images/emoticons/smiley-wink.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_worried {background : url(../../openolat/images/emoticons/smiley-roll-blue.png) no-repeat; width: 18px; height: 18px;}
img.b_emoticons_angel {background : url(../../openolat/images/emoticons/smiley-angel.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_angry {background : url(../../openolat/images/emoticons/smiley-mad.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_blushing {background : url(../../openolat/images/emoticons/smiley-red.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_confused {background : url(../../openolat/images/emoticons/smiley-confuse.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_cool {background : url(../../openolat/images/emoticons/smiley-cool.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_cry {background : url(../../openolat/images/emoticons/smiley-cry.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_devil {background : url(../../openolat/images/emoticons/smiley-evil.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_grin {background : url(../../openolat/images/emoticons/smiley-grin.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_kiss {background : url(../../openolat/images/emoticons/smiley-kiss.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_ohoh {background : url(../../openolat/images/emoticons/smiley-eek.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_sad {background : url(../../openolat/images/emoticons/smiley-sad.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_sick {background : url(../../openolat/images/emoticons/smiley-sad-blue.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_smile {background : url(../../openolat/images/emoticons/smiley.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_tongue {background : url(../../openolat/images/emoticons/smiley-razz.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_ugly {background : url(../../openolat/images/emoticons/smiley-money.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_weird {background : url(../../openolat/images/emoticons/smiley-nerd.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_wink {background : url(../../openolat/images/emoticons/smiley-wink.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_worried {background : url(../../openolat/images/emoticons/smiley-roll-blue.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_up {background : url(../../openolat/images/emoticons/thumb-up.png) no-repeat; width: 16px; height: 16px;}
img.b_emoticons_down {background : url(../../openolat/images/emoticons/thumb.png) no-repeat; width: 16px; height: 16px;}
/** ---------------------- EXT JS PATCHES ------------------ **/
/* (are needed here in content.css , e.g. glossary tooltip in iframes...) */
......
src/main/webapp/static/themes/openolat/images/emoticons/thumb-up.png

754 B

src/main/webapp/static/themes/openolat/images/emoticons/thumb.png

806 B

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