Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/themes/Attic/CSSThemeVisualElement.hbm.xml,v diff -u -r1.5 -r1.6 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml 23 Mar 2006 23:53:42 -0000 1.5 +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml 1 Feb 2007 03:43:26 -0000 1.6 @@ -81,7 +81,19 @@ not-null="true" - + + true + + @hibernate.property + column="image_directory" + length="100" + + Index: lams_common/db/model/lams_11.clay =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/model/lams_11.clay,v diff -u -r1.72 -r1.73 --- lams_common/db/model/lams_11.clay 9 Jan 2007 03:25:50 -0000 1.72 +++ lams_common/db/model/lams_11.clay 1 Feb 2007 03:44:19 -0000 1.73 @@ -1,18 +1,18 @@ - + - + - + - + - + @@ -25,7 +25,7 @@ - + @@ -38,26 +38,26 @@ - + - + - + - + @@ -66,21 +66,21 @@ - + - +
- + - + @@ -93,32 +93,32 @@ - + - + - +
- + - + @@ -131,32 +131,32 @@ - + - + - +
- + - + @@ -169,32 +169,32 @@ - + - + - +
- + - + @@ -207,7 +207,7 @@ - + @@ -220,26 +220,26 @@ - + - + - + - + @@ -252,7 +252,7 @@ - + @@ -265,7 +265,7 @@ - + @@ -278,7 +278,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -304,7 +304,7 @@ - + @@ -317,7 +317,7 @@ - + @@ -330,7 +330,7 @@ - + @@ -343,7 +343,7 @@ - + @@ -356,7 +356,7 @@ - + @@ -369,7 +369,7 @@ - + @@ -382,7 +382,7 @@ - + @@ -395,7 +395,7 @@ - + @@ -408,13 +408,13 @@ - + - + @@ -427,7 +427,7 @@ - + @@ -440,7 +440,7 @@ - + @@ -453,13 +453,13 @@ - + - + @@ -472,7 +472,7 @@ - + @@ -485,7 +485,7 @@ - + @@ -498,7 +498,7 @@ - + @@ -511,7 +511,7 @@ - + @@ -524,7 +524,7 @@ - + @@ -537,7 +537,7 @@ - + @@ -550,26 +550,26 @@ - + - + - + - + @@ -582,7 +582,7 @@ - + @@ -595,7 +595,7 @@ - + @@ -608,14 +608,14 @@ - + - + @@ -629,90 +629,90 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -721,37 +721,37 @@ - + - + - + - + - + - +
- + - + @@ -764,32 +764,32 @@ - + - + - +
- + - + @@ -802,7 +802,7 @@ - + @@ -815,20 +815,20 @@ - + - + - + @@ -841,7 +841,7 @@ - + @@ -854,7 +854,7 @@ - + @@ -867,7 +867,7 @@ - + @@ -880,13 +880,13 @@ - + - + @@ -899,25 +899,25 @@ - + - + - + - + @@ -930,13 +930,13 @@ - + - + @@ -956,7 +956,7 @@ - + @@ -969,7 +969,7 @@ - + @@ -982,7 +982,7 @@ - + @@ -995,54 +995,54 @@ - + - + - + - + - + - + - + - + @@ -1051,29 +1051,29 @@ - + - + - + - +
- + - + @@ -1086,14 +1086,14 @@ - + - + @@ -1106,7 +1106,7 @@ - + @@ -1120,13 +1120,13 @@ - + - + @@ -1135,21 +1135,21 @@ - + - +
- + - + @@ -1162,7 +1162,7 @@ - + @@ -1175,7 +1175,7 @@ - + @@ -1188,7 +1188,7 @@ - + @@ -1201,7 +1201,7 @@ - + @@ -1214,7 +1214,7 @@ - + @@ -1227,7 +1227,7 @@ - + @@ -1241,13 +1241,13 @@ - + - + @@ -1256,21 +1256,21 @@ - + - +
- + - + @@ -1283,20 +1283,20 @@ - + - + - + @@ -1309,31 +1309,31 @@ - + - + - +
- + - + @@ -1346,7 +1346,7 @@ - + @@ -1359,20 +1359,20 @@ - + - + - + @@ -1385,7 +1385,7 @@ - + @@ -1398,7 +1398,7 @@ - + @@ -1411,13 +1411,13 @@ - + - + @@ -1430,7 +1430,7 @@ - + @@ -1444,27 +1444,27 @@ - + - + - + - + @@ -1473,29 +1473,29 @@ - + - + - + - +
- + - + @@ -1508,28 +1508,28 @@ - + - + - + - + @@ -1542,7 +1542,7 @@ - + @@ -1555,13 +1555,13 @@ - + - + @@ -1574,7 +1574,7 @@ - + @@ -1587,7 +1587,7 @@ - + @@ -1600,7 +1600,7 @@ - + @@ -1613,7 +1613,7 @@ - + @@ -1626,7 +1626,7 @@ - + @@ -1639,7 +1639,7 @@ - + @@ -1652,7 +1652,7 @@ - + @@ -1665,48 +1665,48 @@ - + - + - + - + - + - + - + @@ -1715,33 +1715,33 @@ - + - + - + - + - +
- + - + @@ -1754,43 +1754,43 @@ - + - + - + - + - +
- + - + @@ -1803,48 +1803,48 @@ - + - + - + - + - + - +
- + - + @@ -1857,126 +1857,126 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1989,13 +1989,13 @@ - + - + @@ -2008,7 +2008,7 @@ - + @@ -2021,7 +2021,7 @@ - + @@ -2034,7 +2034,7 @@ - + @@ -2047,14 +2047,14 @@ - + - + @@ -2067,7 +2067,7 @@ - + @@ -2081,41 +2081,41 @@ - + - + - + - + - + - + @@ -2124,33 +2124,33 @@ - + - + - + - + - +
- + - + @@ -2163,7 +2163,7 @@ - + @@ -2176,7 +2176,7 @@ - + @@ -2190,20 +2190,20 @@ - + - + - + @@ -2212,25 +2212,25 @@ - + - + - +
- + - + @@ -2243,7 +2243,7 @@ - + @@ -2256,7 +2256,7 @@ - + @@ -2270,20 +2270,20 @@ - + - + - + @@ -2292,25 +2292,25 @@ - + - + - +
- + - + @@ -2323,7 +2323,7 @@ - + @@ -2336,7 +2336,7 @@ - + @@ -2349,28 +2349,28 @@ - + - + - + - + @@ -2379,20 +2379,20 @@ - + - +
- + - + @@ -2405,7 +2405,7 @@ - + @@ -2418,14 +2418,14 @@ - + - + @@ -2438,19 +2438,19 @@ - + - + - + @@ -2464,20 +2464,20 @@ - + - + - + @@ -2486,21 +2486,21 @@ - + - +
- + - + @@ -2513,7 +2513,7 @@ - + @@ -2526,7 +2526,7 @@ - + @@ -2539,26 +2539,26 @@ - + - + - + - + @@ -2571,7 +2571,7 @@ - + @@ -2584,7 +2584,7 @@ - + @@ -2597,31 +2597,31 @@ - + - + - + - + - + @@ -2634,7 +2634,7 @@ - + @@ -2648,41 +2648,41 @@ - + - + - + - + - + - + @@ -2692,11 +2692,11 @@
- + - + @@ -2709,7 +2709,7 @@ - + @@ -2722,7 +2722,7 @@ - + @@ -2735,7 +2735,7 @@ - + @@ -2748,7 +2748,7 @@ - + @@ -2761,19 +2761,19 @@ - + - + - + @@ -2786,7 +2786,7 @@ - + @@ -2799,7 +2799,7 @@ - + @@ -2812,7 +2812,7 @@ - + @@ -2826,41 +2826,41 @@ - + - + - + - + - + - + @@ -2869,18 +2869,18 @@ - +
- + - + @@ -2900,21 +2900,21 @@ - + - + - + @@ -2935,7 +2935,7 @@ - + @@ -2948,7 +2948,7 @@ - + @@ -2961,7 +2961,7 @@ - + @@ -2974,7 +2974,7 @@ - + @@ -2987,7 +2987,7 @@ - + @@ -3000,109 +3000,109 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3112,11 +3112,11 @@
- + - + @@ -3129,7 +3129,7 @@ - + @@ -3142,7 +3142,7 @@ - + @@ -3155,7 +3155,7 @@ - + @@ -3168,7 +3168,7 @@ - + @@ -3181,13 +3181,13 @@ - + - + @@ -3200,7 +3200,7 @@ - + @@ -3213,61 +3213,61 @@ - + - + - + - + - + - + - + - + - + @@ -3277,11 +3277,11 @@
- + - + @@ -3294,7 +3294,7 @@ - + @@ -3308,21 +3308,21 @@ - + - + - + @@ -3332,11 +3332,11 @@
- + - + @@ -3349,7 +3349,7 @@ - + @@ -3363,21 +3363,21 @@ - + - + - + @@ -3387,11 +3387,11 @@
- + - + @@ -3404,27 +3404,27 @@ - + - +
- + - + @@ -3437,7 +3437,7 @@ - + @@ -3451,21 +3451,21 @@ - + - + - + @@ -3475,11 +3475,11 @@
- + - + @@ -3492,27 +3492,27 @@ - + - +
- + - + @@ -3525,7 +3525,7 @@ - + @@ -3539,13 +3539,13 @@ - + - + @@ -3555,11 +3555,11 @@
- + - + @@ -3572,7 +3572,7 @@ - + @@ -3586,19 +3586,19 @@ - + - + - + @@ -3608,11 +3608,11 @@
- + - + @@ -3625,7 +3625,7 @@ - + @@ -3639,19 +3639,19 @@ - + - + - + @@ -3661,11 +3661,11 @@
- + - + @@ -3678,27 +3678,27 @@ - + - +
- + - + @@ -3711,28 +3711,28 @@ - + - + - + - + @@ -3745,27 +3745,27 @@ - + - +
- + - + @@ -3778,27 +3778,27 @@ - + - +
- + - + @@ -3811,15 +3811,15 @@ - + - + @@ -3834,7 +3834,7 @@ - + @@ -3847,15 +3847,15 @@ - + - + @@ -3869,7 +3869,7 @@ - + @@ -3882,34 +3882,34 @@ - + - + - +
- + - + @@ -3922,7 +3922,7 @@ - + @@ -3935,7 +3935,7 @@ - + @@ -3949,20 +3949,20 @@ - + - + - + @@ -3979,7 +3979,7 @@ - + @@ -3992,7 +3992,7 @@ - + @@ -4005,7 +4005,7 @@ - + @@ -4018,13 +4018,13 @@ - + - + @@ -4038,13 +4038,13 @@ - + - + @@ -4054,11 +4054,11 @@
- + - + @@ -4071,7 +4071,7 @@ - + @@ -4084,21 +4084,21 @@ - + - + - + @@ -4112,13 +4112,13 @@ - + - + @@ -4132,7 +4132,7 @@ - + @@ -4145,7 +4145,7 @@ - + @@ -4158,27 +4158,27 @@ - + - + - + - + @@ -4191,7 +4191,7 @@ - + @@ -4205,13 +4205,13 @@ - + - + @@ -4221,11 +4221,11 @@
- + - + @@ -4238,27 +4238,27 @@ - + - +
- + - + @@ -4271,27 +4271,27 @@ - + - +
- + - + @@ -4304,7 +4304,7 @@ - + @@ -4317,7 +4317,7 @@ - + @@ -4330,13 +4330,13 @@ - + - + @@ -4349,21 +4349,21 @@ - + - + - + @@ -4373,11 +4373,11 @@
- + - + @@ -4390,27 +4390,27 @@ - + - +
- + - + @@ -4423,7 +4423,7 @@ - + @@ -4436,33 +4436,33 @@ - + - + - + - + - + @@ -4475,7 +4475,7 @@ - + @@ -4488,7 +4488,7 @@ - + @@ -4501,41 +4501,41 @@ - + - + - + - + - + - + @@ -4545,11 +4545,11 @@
- + - + @@ -4562,27 +4562,27 @@ - + - +
- + - + @@ -4595,21 +4595,21 @@ - + - + - + @@ -4622,7 +4622,7 @@ - + @@ -4634,15 +4634,22 @@ + + + + + + + - + - + @@ -4652,11 +4659,11 @@
- + - + @@ -4669,7 +4676,7 @@ - + @@ -4682,28 +4689,28 @@ - + - + - + - + @@ -4717,13 +4724,13 @@ - + - + @@ -4739,7 +4746,7 @@ - + @@ -4752,7 +4759,7 @@ - + @@ -4766,13 +4773,13 @@ - + - + @@ -4786,7 +4793,7 @@ - + @@ -4812,86 +4819,86 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4905,7 +4912,7 @@ - + @@ -4918,29 +4925,29 @@ - + - + - + - + @@ -4950,7 +4957,7 @@ - + @@ -4963,7 +4970,7 @@ - + @@ -4976,7 +4983,7 @@ - + @@ -4990,20 +4997,20 @@ - + - + - + @@ -5013,11 +5020,11 @@
- + - + @@ -5030,27 +5037,27 @@ - + - +
- + - + @@ -5063,7 +5070,7 @@ - + @@ -5076,7 +5083,7 @@ - + @@ -5090,20 +5097,20 @@ - + - + - + @@ -5113,11 +5120,11 @@
- + - + @@ -5130,48 +5137,48 @@ - + - + - + - + - +
- + - + @@ -5184,22 +5191,22 @@ - + - + - + @@ -5211,22 +5218,22 @@ - + - + - + Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/create_lams_11_tables.sql,v diff -u -r1.87 -r1.88 --- lams_common/db/sql/create_lams_11_tables.sql 20 Dec 2006 04:57:27 -0000 1.87 +++ lams_common/db/sql/create_lams_11_tables.sql 1 Feb 2007 03:44:21 -0000 1.88 @@ -250,6 +250,7 @@ , description VARCHAR(100) , parent_id BIGINT(20) , theme_flag TINYINT(1) NOT NULL DEFAULT 0 + , image_directory VARCHAR(100) , PRIMARY KEY (theme_ve_id) , INDEX (parent_id) , CONSTRAINT FK_lams_css_theme_ve_2 FOREIGN KEY (parent_id) Index: lams_common/db/sql/insert_users.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/Attic/insert_users.sql,v diff -u -r1.39 -r1.40 --- lams_common/db/sql/insert_users.sql 7 Jan 2007 06:13:43 -0000 1.39 +++ lams_common/db/sql/insert_users.sql 1 Feb 2007 03:44:21 -0000 1.40 @@ -7,8 +7,8 @@ SET FOREIGN_KEY_CHECKS=0; -- themes and styles -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag) VALUES (1, "default", "Default Flash style", null, 1); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag) VALUES (2, "defaultHTML", "Default HTML style", null, 1); +INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (1, "default", "Default Flash style", null, 1, null); +INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (2, "defaultHTML", "Default HTML style", null, 1, "css"); insert into lams_workspace (workspace_id, name, default_fld_id) values(1,'ROOT',1); insert into lams_workspace (workspace_id, name, default_fld_id, def_run_seq_fld_id) values(2,'Developers Playpen',2,22); Index: lams_common/src/java/org/lamsfoundation/lams/themes/CSSThemeVisualElement.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/Attic/CSSThemeVisualElement.java,v diff -u -r1.8 -r1.9 --- lams_common/src/java/org/lamsfoundation/lams/themes/CSSThemeVisualElement.java 17 Sep 2006 06:14:16 -0000 1.8 +++ lams_common/src/java/org/lamsfoundation/lams/themes/CSSThemeVisualElement.java 1 Feb 2007 03:43:16 -0000 1.9 @@ -57,6 +57,10 @@ /** persistent field */ private boolean theme; + + /** persistent field */ + private String imageDirectory; + /** nullable persistent field */ private CSSThemeVisualElement parentTheme; @@ -68,11 +72,12 @@ private Set elements; /** full constructor */ - public CSSThemeVisualElement(Long id, String name, String description, boolean theme, CSSThemeVisualElement parentTheme, Set styles, Set elements) { + public CSSThemeVisualElement(Long id, String name, String description, boolean theme, String imageDirectory, CSSThemeVisualElement parentTheme, Set styles, Set elements) { this.id = id; this.name = name; this.description = description; this.theme = theme; + this.imageDirectory = imageDirectory; this.parentTheme = parentTheme; this.styles = styles; this.elements = elements; @@ -149,6 +154,20 @@ } /** + * @hibernate.property + * column="image_directory" + * length="100" + * + */ + public String getImageDirectory() { + return this.imageDirectory; + } + + public void setImageDirectory(String imageDirectory) { + this.imageDirectory = imageDirectory; + } + + /** * If a theme, then this is the base style. If a visual element, then * it is the style for this element. */ Index: lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java,v diff -u -r1.10 -r1.11 --- lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java 17 Sep 2006 06:14:25 -0000 1.10 +++ lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java 1 Feb 2007 03:43:16 -0000 1.11 @@ -25,6 +25,7 @@ import java.io.IOException; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; import org.lamsfoundation.lams.themes.dao.ICSSThemeDAO; import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.themes.exception.ThemeException; @@ -72,14 +73,23 @@ /** * Returns a string representing the requested theme in WDDX format * - * @param learningDesignID The learning_design_id of the design whose WDDX packet is requested - * @return String The requested LearningDesign in WDDX format + * @param themeId The id of the theme whose WDDX packet is requested + * @return String The requested theme in WDDX format * @throws Exception */ - public String getTheme(Long themeId)throws IOException; + public String getThemeWDDX(Long themeId)throws IOException; + /** + * Returns a theme + */ + public CSSThemeVisualElement getTheme(Long themeId); /** + * Returns a theme based on the name. + */ + public CSSThemeVisualElement getTheme(String themeName); + + /** * This method returns a list of all available themes in * WDDX format. We need to work out if this should be restricted * by user. Index: lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java,v diff -u -r1.11 -r1.12 --- lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java 17 Jan 2007 01:16:51 -0000 1.11 +++ lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java 1 Feb 2007 03:43:16 -0000 1.12 @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -149,13 +150,13 @@ /** * Returns a string representing the requested theme in WDDX format * - * @param learningDesignID The learning_design_id of the design whose WDDX packet is requested - * @return String The requested LearningDesign in WDDX format + * @param themeId The id of the theme whose WDDX packet is requested + * @return String The requested theme in WDDX format * @throws Exception */ - public String getTheme(Long themeId)throws IOException { + public String getThemeWDDX(Long themeId)throws IOException { FlashMessage flashMessage= null; - CSSThemeVisualElement theme = themeDAO.getThemeById(themeId); + CSSThemeVisualElement theme = getTheme(themeId); if(theme==null) flashMessage = FlashMessage.getNoSuchTheme("wddxPacket",themeId); else{ @@ -167,6 +168,26 @@ /** + * Returns a theme + */ + public CSSThemeVisualElement getTheme(Long themeId) { + return themeDAO.getThemeById(themeId); + } + + + /** + * Returns a theme based on the name. + */ + public CSSThemeVisualElement getTheme(String themeName) { + List themes = themeDAO.getThemeByName(themeName); + if ( themes != null && themes.size() > 0 ) + return (CSSThemeVisualElement) themes.get(0); + else + return null; + } + + + /** * This method returns a list of all available themes in * WDDX format. We need to work out if this should be restricted * by user. Index: lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java,v diff -u -r1.8 -r1.9 --- lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java 31 Jan 2007 05:52:04 -0000 1.8 +++ lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java 1 Feb 2007 03:43:16 -0000 1.9 @@ -36,7 +36,7 @@ public class CSSThemeUtil { // private static Logger log = Logger.getLogger(CSSThemeUtil.class); - public static String DEFAULT_HTML_THEME = "defaultHTML"; + private static String DEFAULT_HTML_THEME = "defaultHTML"; /** * Will return a list of stylesheets for the current user. @@ -63,7 +63,7 @@ if (theme != null ) { userThemeFound = true; String themeName = theme.getName(); - if ( themeName != null && ! themeName.equals(DEFAULT_HTML_THEME) ) { + if ( themeName != null && ! isLAMSDefaultTheme(themeName) ) { themeList.add(theme.getName()); } } @@ -98,4 +98,10 @@ return theme; } + + // Is this theme the LAMS basic theme, which must always be included on a web page? + // This is NOT the server default theme - which may be a custom theme. + public static boolean isLAMSDefaultTheme(String themeName) { + return themeName.equals(DEFAULT_HTML_THEME); + } } Index: lams_common/test/java/org/lamsfoundation/lams/theme/service/TestThemeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/test/java/org/lamsfoundation/lams/theme/service/Attic/TestThemeService.java,v diff -u -r1.5 -r1.6 --- lams_common/test/java/org/lamsfoundation/lams/theme/service/TestThemeService.java 17 Sep 2006 06:14:24 -0000 1.5 +++ lams_common/test/java/org/lamsfoundation/lams/theme/service/TestThemeService.java 1 Feb 2007 03:43:34 -0000 1.6 @@ -69,7 +69,7 @@ } public void testGetTheme() throws Exception{ - String str = themeService.getTheme(TEST_THEME_ID); + String str = themeService.getThemeWDDX(TEST_THEME_ID); System.out.println(str); assertTrue("Finds ruby theme", str.indexOf("ruby") != -1); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml,v diff -u -r1.19 -r1.20 --- lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml 26 Sep 2006 05:53:05 -0000 1.19 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/learningApplicationContext.xml 1 Feb 2007 03:42:58 -0000 1.20 @@ -65,6 +65,7 @@ + Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java,v diff -u -r1.25 -r1.26 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java 27 Sep 2006 04:24:36 -0000 1.25 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java 1 Feb 2007 03:42:59 -0000 1.26 @@ -31,8 +31,11 @@ import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.Vector; import javax.servlet.http.Cookie; @@ -41,20 +44,23 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.learning.export.ActivityPortfolio; -import org.lamsfoundation.lams.learning.export.NotebookPortfolio; import org.lamsfoundation.lams.learning.export.ExportPortfolioConstants; import org.lamsfoundation.lams.learning.export.ExportPortfolioException; +import org.lamsfoundation.lams.learning.export.NotebookPortfolio; import org.lamsfoundation.lams.learning.export.Portfolio; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.dao.ILessonDAO; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; import org.lamsfoundation.lams.tool.service.ILamsCoreToolService; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.util.CSSThemeUtil; import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.FileUtilException; import org.lamsfoundation.lams.util.HttpUrlConnectionUtil; @@ -88,6 +94,7 @@ private IBaseDAO baseDAO; private ILessonDAO lessonDAO; protected MessageService messageService; + private IThemeService themeService; /** @@ -133,6 +140,10 @@ this.messageService = messageService; } + public void setThemeService(IThemeService themeService) { + this.themeService = themeService; + } + /** @see org.lamsfoundation.lams.learning.export.service.IExportPortfolioService#exportPortfolioForTeacher(org.lamsfoundation.lams.lesson.Lesson) */ public Portfolio exportPortfolioForTeacher(Long lessonId, Cookie[] cookies) { @@ -531,4 +542,20 @@ } } + /** Gets the themes for the current user. This is used to determine the stylesheets + * included in the export file. We need the full theme, not just the name, so we can get + * the directory names for the images. */ + public Collection getUserThemes() { + List themeNames = CSSThemeUtil.getAllUserThemes(); + Set userThemes = new HashSet(); + for ( String themeName: themeNames) { + CSSThemeVisualElement theme = themeService.getTheme(themeName); + if ( theme != null ) { + userThemes.add(theme); + } + } + return userThemes; + } + + } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java,v diff -u -r1.14 -r1.15 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java 27 Sep 2006 04:24:37 -0000 1.14 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java 1 Feb 2007 03:42:59 -0000 1.15 @@ -24,10 +24,13 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learning.export.service; +import java.util.Collection; + import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import org.lamsfoundation.lams.learning.export.Portfolio; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; import org.lamsfoundation.lams.tool.ToolAccessMode; /** * @author mtruong @@ -108,5 +111,9 @@ /** Generate the main notebook page, given this portfolio */ public void generateNotebookPage(HttpServletRequest request, Portfolio portfolio, Cookie[] cookies); + /** Gets the themes for the current user. This is used to determine the stylesheets + * included in the export file. We need the full theme, not just the name, so we can get + * the directory names for the images. */ + public Collection getUserThemes(); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java,v diff -u -r1.6 -r1.7 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java 1 Dec 2006 04:33:31 -0000 1.6 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java 1 Feb 2007 03:42:58 -0000 1.7 @@ -33,16 +33,16 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.util.CSSThemeUtil; +import org.lamsfoundation.lams.themes.CSSThemeVisualElement; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.HttpUrlConnectionUtil; @@ -60,16 +60,18 @@ String outputDirectory = null; String centralPath = null; boolean rtl = false; + Collection themes = null; /** * @param centralPath the directory path to the lams-central.war. Assumes that it is an expanded war. */ - public CSSBundler(HttpServletRequest request, Cookie[] cookies, String outputDirectory) { + public CSSBundler(HttpServletRequest request, Cookie[] cookies, String outputDirectory, Collection themes) { filesToCopy = new HashMap(); directoriesRequired = new ArrayList(); this.request = request; this.cookies = cookies; this.outputDirectory = outputDirectory; + this.themes = themes != null ? themes : new ArrayList(); this.centralPath = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR); if ( centralPath == null ) { @@ -123,20 +125,15 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort(); - List themeList = CSSThemeUtil.getAllUserThemes(); - - Iterator i = themeList.iterator(); - - while (i.hasNext()) - { - String theme = (String)i.next(); + for ( CSSThemeVisualElement theme : themes) { + String themeName = theme.getName(); - String url = (!rtl)? basePath + "/lams/css/" + theme + ".css" : basePath + "/lams/css/" + theme + "_" + RTL_DIR + ".css"; - HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? theme + ".css" : theme + "_" + RTL_DIR + ".css", cookies); //cookies aren't really needed here. + String url = (!rtl)? basePath + "/lams/css/" + themeName + ".css" : basePath + "/lams/css/" + themeName + "_" + RTL_DIR + ".css"; + HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? themeName + ".css" : themeName + "_" + RTL_DIR + ".css", cookies); //cookies aren't really needed here. - url = (!rtl)? basePath + "/lams/css/" + theme + "_learner.css" : basePath + "/lams/css/" + theme + "_" + RTL_DIR + "_learner.css" ; - HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? theme + "_learner.css" : theme + "_" + RTL_DIR + "_learner.css", cookies); //cookies aren't really needed here. -} + url = (!rtl)? basePath + "/lams/css/" + themeName + "_learner.css" : basePath + "/lams/css/" + themeName + "_" + RTL_DIR + "_learner.css" ; + HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? themeName + "_learner.css" : themeName + "_" + RTL_DIR + "_learner.css", cookies); //cookies aren't really needed here. + } // include the special IE stylesheet String url = basePath + "/lams/css/ie-styles.css"; @@ -172,16 +169,14 @@ String cssDirectory = outputDirectory+File.separatorChar+"css"; directoriesRequired.add(cssDirectory); - List themeList = CSSThemeUtil.getAllUserThemes(); - Iterator i = themeList.iterator(); - while (i.hasNext()) - { - String theme = (String)i.next(); + for ( CSSThemeVisualElement theme : themes) { - String themeFilename = (!rtl) ? theme + ".css" : theme + "_" + RTL_DIR + ".css"; + String themeName = theme.getName(); + + String themeFilename = (!rtl) ? themeName + ".css" : themeName + "_" + RTL_DIR + ".css"; addThemeFile(cssDirectory, themeFilename); - themeFilename = (!rtl) ? theme + "_learner.css" : theme + "_" + RTL_DIR + "_learner.css"; + themeFilename = (!rtl) ? themeName + "_learner.css" : themeName + "_" + RTL_DIR + "_learner.css"; addThemeFile(cssDirectory, themeFilename); } @@ -200,23 +195,31 @@ } private void setupImageList() { + + for ( CSSThemeVisualElement theme : themes) { + + String dirName = theme.getImageDirectory(); + if ( dirName != null ) { + + String imageDirectory = centralPath+File.separatorChar+"images"+File.separatorChar+dirName; + String outputImageDirectory = outputDirectory+File.separatorChar+"images"+File.separatorChar+dirName; + + directoriesRequired.add(outputImageDirectory); - // TODO add an entry in the theme definition that defines where to find all the stylesheet images. - String imageDirectory = centralPath+File.separatorChar+"images"+File.separatorChar+"css"; - String outputImageDirectory = outputDirectory+File.separatorChar+"images"+File.separatorChar+"css"; - directoriesRequired.add(outputImageDirectory); + File dir = new File(imageDirectory); + if ( ! dir.canRead() || ! dir.isDirectory() ) { + log.error("Unable to read css image directory "+dir.getAbsolutePath()); + + } else { - File dir = new File(imageDirectory); - if ( ! dir.canRead() || ! dir.isDirectory() ) { - log.error("Unable to read css image directory "+dir.getAbsolutePath()); - - } else { - - File[] files = dir.listFiles(); - for ( File imageFile: files ) { - filesToCopy.put(outputImageDirectory+File.separatorChar+imageFile.getName(),imageFile); + File[] files = dir.listFiles(); + for ( File imageFile: files ) { + filesToCopy.put(outputImageDirectory+File.separatorChar+imageFile.getName(),imageFile); + } + } } } + } private void createDirectories() { Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MainExportServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MainExportServlet.java,v diff -u -r1.19 -r1.20 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MainExportServlet.java 27 Sep 2006 04:24:36 -0000 1.19 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/MainExportServlet.java 1 Feb 2007 03:42:58 -0000 1.20 @@ -137,7 +137,7 @@ //bundle the stylesheet with the package - CSSBundler bundler = new CSSBundler(request, cookies, exportTmpDir); + CSSBundler bundler = new CSSBundler(request, cookies, exportTmpDir, exportService.getUserThemes()); bundler.bundleStylesheet(); // zip up the contents of the temp export folder