From be91333073791d8c9312bd5401b8c7e74a0d02d5 Mon Sep 17 00:00:00 2001
From: Matthai Kurian <matthai.kurian@frentix.com>
Date: Mon, 23 Jul 2012 11:58:06 +0200
Subject: [PATCH] OO-307: Added ways to configure short/long titles in course
 display

---
 .../editor/NodeConfigFormController.java      |  4 +++
 .../editor/_i18n/LocalStrings_de.properties   |  2 ++
 .../editor/_i18n/LocalStrings_en.properties   |  2 ++
 .../org/olat/course/nodes/CourseNode.java     |  2 ++
 .../course/nodes/TitledWrapperHelper.java     | 34 ++++++++++++++++---
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/olat/course/editor/NodeConfigFormController.java b/src/main/java/org/olat/course/editor/NodeConfigFormController.java
index 0ccff3e7d68..9973d7e56bd 100644
--- a/src/main/java/org/olat/course/editor/NodeConfigFormController.java
+++ b/src/main/java/org/olat/course/editor/NodeConfigFormController.java
@@ -48,7 +48,9 @@ public class NodeConfigFormController extends FormBasicController {
 	public final static int SHORT_TITLE_MAX_LENGTH =25;
 	
 	private final static String[] displayOptionsKeys = new String[]{
+		CourseNode.DISPLAY_OPTS_SHORT_TITLE_DESCRIPTION_CONTENT,
 		CourseNode.DISPLAY_OPTS_TITLE_DESCRIPTION_CONTENT,
+		CourseNode.DISPLAY_OPTS_SHORT_TITLE_CONTENT,
 		CourseNode.DISPLAY_OPTS_TITLE_CONTENT,
 		CourseNode.DISPLAY_OPTS_CONTENT};
 	
@@ -155,7 +157,9 @@ public class NodeConfigFormController extends FormBasicController {
 		objectives.setMaxLength(4000);
 		
 		String[] values = new String[]{
+				translate("nodeConfigForm.short_title_desc_content"),
 				translate("nodeConfigForm.title_desc_content"),
+				translate("nodeConfigForm.short_title_content"),
 				translate("nodeConfigForm.title_content"),
 				translate("nodeConfigForm.content_only")};
 		displayOptions = uifactory.addDropdownSingleselect("displayOptions", "nodeConfigForm.display_options", formLayout, displayOptionsKeys, values, null);
diff --git a/src/main/java/org/olat/course/editor/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/editor/_i18n/LocalStrings_de.properties
index b068606c128..88f775b5b51 100644
--- a/src/main/java/org/olat/course/editor/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/course/editor/_i18n/LocalStrings_de.properties
@@ -415,7 +415,9 @@ nodeConfigForm.menutitle=Kurzer Titel
 nodeConfigForm.save=Speichern
 nodeConfigForm.title=Titel und Beschreibung des Kursbausteins
 nodeConfigForm.display_options=Anzeige
+nodeConfigForm.short_title_desc_content=Kurztitel, Beschreibung und Inhalt
 nodeConfigForm.title_desc_content=Titel, Beschreibung und Inhalt
+nodeConfigForm.short_title_content=Kurztitel und Inhalt
 nodeConfigForm.title_content=Titel und Inhalt
 nodeConfigForm.content_only=Nur Inhalt
 nodeEdit.extLink=Externer Link
diff --git a/src/main/java/org/olat/course/editor/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/editor/_i18n/LocalStrings_en.properties
index f43df4f17a3..8249cb1cb81 100644
--- a/src/main/java/org/olat/course/editor/_i18n/LocalStrings_en.properties
+++ b/src/main/java/org/olat/course/editor/_i18n/LocalStrings_en.properties
@@ -407,7 +407,9 @@ nodeConfigForm.menutitle=Short title
 nodeConfigForm.save=Save
 nodeConfigForm.title=Title and description of course element
 nodeConfigForm.title_content=Title and content
+nodeConfigForm.short_title_content=Short title and content
 nodeConfigForm.title_desc_content=Title, description and content
+nodeConfigForm.short_title_desc_content=Short title, description and content
 nodeEdit.extLink=External link
 nodeEdit.intLink=Internal link (do not open in new window)
 nodeEdit.links=Set link for this course element
diff --git a/src/main/java/org/olat/course/nodes/CourseNode.java b/src/main/java/org/olat/course/nodes/CourseNode.java
index 32e99b0305e..8016b2d3d00 100644
--- a/src/main/java/org/olat/course/nodes/CourseNode.java
+++ b/src/main/java/org/olat/course/nodes/CourseNode.java
@@ -54,7 +54,9 @@ import org.olat.repository.RepositoryEntry;
  */
 public interface CourseNode extends INode, ShortName {
 	
+	public static final String DISPLAY_OPTS_SHORT_TITLE_DESCRIPTION_CONTENT = "shorttitle+desc+content";
 	public static final String DISPLAY_OPTS_TITLE_DESCRIPTION_CONTENT = "title+desc+content";
+	public static final String DISPLAY_OPTS_SHORT_TITLE_CONTENT = "shorttitle+content";
 	public static final String DISPLAY_OPTS_TITLE_CONTENT = "title+content";
 	public static final String DISPLAY_OPTS_CONTENT = "content";
 
diff --git a/src/main/java/org/olat/course/nodes/TitledWrapperHelper.java b/src/main/java/org/olat/course/nodes/TitledWrapperHelper.java
index d5a7937212e..0b5e667125c 100644
--- a/src/main/java/org/olat/course/nodes/TitledWrapperHelper.java
+++ b/src/main/java/org/olat/course/nodes/TitledWrapperHelper.java
@@ -40,7 +40,7 @@ public class TitledWrapperHelper {
 		String displayOption = courseNode.getDisplayOption();
 		if(CourseNode.DISPLAY_OPTS_CONTENT.equals(displayOption)) {
 			return controller;
-		} else if (CourseNode.DISPLAY_OPTS_TITLE_CONTENT.equals(displayOption)) {
+		} else if (CourseNode.DISPLAY_OPTS_SHORT_TITLE_CONTENT.equals(displayOption)) {
 			TitleInfo titleInfo = new TitleInfo(null, courseNode.getShortTitle(), null, courseNode.getIdent());
 			titleInfo.setDescriptionCssClass("o_course_run_objectives");
 			TitledWrapperController titledController = new TitledWrapperController(ureq, wControl, controller, "o_course_run", titleInfo);
@@ -48,13 +48,39 @@ public class TitledWrapperHelper {
 				titledController.setTitleCssClass(" b_with_small_icon_left " + iconCssClass + " ");
 			}
 			return titledController; 
+		} else if (CourseNode.DISPLAY_OPTS_TITLE_CONTENT.equals(displayOption)) {
+			TitleInfo titleInfo = new TitleInfo(null, courseNode.getLongTitle(), null, courseNode.getIdent());
+			titleInfo.setDescriptionCssClass("o_course_run_objectives");
+			TitledWrapperController titledController = new TitledWrapperController(ureq, wControl, controller, "o_course_run", titleInfo);
+			if (StringHelper.containsNonWhitespace(iconCssClass)) {
+				titledController.setTitleCssClass(" b_with_small_icon_left " + iconCssClass + " ");
+			}
+			return titledController; 
+		} else if (CourseNode.DISPLAY_OPTS_SHORT_TITLE_DESCRIPTION_CONTENT.equals(displayOption)) {
+			String title = courseNode.getShortTitle();
+			String description = null;
+			if (StringHelper.containsNonWhitespace(courseNode.getLearningObjectives())) {
+				if (StringHelper.containsNonWhitespace(title)) {
+					description = "<h4>" + title + "</h4>" + courseNode.getLearningObjectives();
+				} else {
+					description = courseNode.getLearningObjectives();
+				}
+			}
+			
+			TitleInfo titleInfo = new TitleInfo(null, courseNode.getShortTitle(), description, courseNode.getIdent());
+			titleInfo.setDescriptionCssClass("o_course_run_objectives");
+			TitledWrapperController titledController = new TitledWrapperController(ureq, wControl, controller, "o_course_run", titleInfo);
+			if (StringHelper.containsNonWhitespace(iconCssClass)) {
+				titledController.setTitleCssClass(" b_with_small_icon_left " + iconCssClass + " ");
+			}
+			return titledController; 
 		} else if (CourseNode.DISPLAY_OPTS_TITLE_DESCRIPTION_CONTENT.equals(displayOption)) {
 
-			String longTitle = courseNode.getLongTitle();
+			String title = courseNode.getLongTitle();
 			String description = null;
 			if (StringHelper.containsNonWhitespace(courseNode.getLearningObjectives())) {
-				if (StringHelper.containsNonWhitespace(longTitle)) {
-					description = "<h4>" + longTitle + "</h4>" + courseNode.getLearningObjectives();
+				if (StringHelper.containsNonWhitespace(title)) {
+					description = "<h4>" + title + "</h4>" + courseNode.getLearningObjectives();
 				} else {
 					description = courseNode.getLearningObjectives();
 				}
-- 
GitLab