Index: lams_tool_pixlr/conf/hibernate/mappings/org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/conf/hibernate/mappings/org/lamsfoundation/lams/tool/pixlr/model/Attic/PixlrConfigItem.hbm.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/conf/hibernate/mappings/org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.hbm.xml 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + Index: lams_tool_pixlr/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.2 -r1.3 --- lams_tool_pixlr/conf/language/lams/ApplicationResources_en_AU.properties 8 Jan 2009 00:23:58 -0000 1.2 +++ lams_tool_pixlr/conf/language/lams/ApplicationResources_en_AU.properties 12 Jan 2009 03:15:39 -0000 1.3 @@ -115,5 +115,8 @@ title.originalImage =Original Image message.imageNotAvailable =Image not available, either it has not yet been edited or it has been deleted. authoring.msg.cancel.save =Do you want to close this window without saving? +admin.pixlrLanguageCSV =Enter the comma-separated language key values supported by Pixlr +admin.formError =The was an error processing the form, please make sure the input text is in comma-separated format: xx,yy,zz +admin.success =Configuration successfully saved. #======= End labels: Exported 103 labels for en AU ===== Index: lams_tool_pixlr/db/sql/create_lams_tool_pixlr.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/db/sql/create_lams_tool_pixlr.sql,v diff -u -r1.3 -r1.4 --- lams_tool_pixlr/db/sql/create_lams_tool_pixlr.sql 8 Jan 2009 03:00:16 -0000 1.3 +++ lams_tool_pixlr/db/sql/create_lams_tool_pixlr.sql 12 Jan 2009 03:15:39 -0000 1.4 @@ -5,14 +5,28 @@ drop table if exists tl_lapixl10_pixlr; drop table if exists tl_lapixl10_session; drop table if exists tl_lapixl10_user; -create table tl_lapixl10_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, pixlr_uid bigint, primary key (uid)); -create table tl_lapixl10_pixlr (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, reflect_on_activity bit, allow_view_others_images bit, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, image_file_name text, image_width bigint, image_height bigint, reflect_instructions text, primary key (uid)); -create table tl_lapixl10_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), pixlr_uid bigint, primary key (uid)); -create table tl_lapixl10_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, pixlr_session_uid bigint, entry_uid bigint, image_file_name text, imageHeight bigint, imageWidth bigint, imageHidden bit, primary key (uid)); +drop table if exists tl_lapixl10_configuration; +create table tl_lapixl10_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, pixlr_uid bigint, primary key (uid))TYPE=InnoDB; +create table tl_lapixl10_pixlr (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, reflect_on_activity bit, allow_view_others_images bit, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, image_file_name text, image_width bigint, image_height bigint, reflect_instructions text, primary key (uid))TYPE=InnoDB; +create table tl_lapixl10_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), pixlr_uid bigint, primary key (uid))TYPE=InnoDB; +create table tl_lapixl10_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, pixlr_session_uid bigint, entry_uid bigint, image_file_name text, imageHeight bigint, imageWidth bigint, imageHidden bit, primary key (uid))TYPE=InnoDB; +create table tl_lapixl10_configuration (uid bigint not null auto_increment, config_key varchar(30) unique, config_value text, primary key (uid))TYPE=InnoDB; alter table tl_lapixl10_attachment add index FK951F889ACB8ADA74 (pixlr_uid), add constraint FK951F889ACB8ADA74 foreign key (pixlr_uid) references tl_lapixl10_pixlr (uid); alter table tl_lapixl10_session add index FKE5C05E7FCB8ADA74 (pixlr_uid), add constraint FKE5C05E7FCB8ADA74 foreign key (pixlr_uid) references tl_lapixl10_pixlr (uid); alter table tl_lapixl10_user add index FK9A39C08236E23005 (pixlr_session_uid), add constraint FK9A39C08236E23005 foreign key (pixlr_session_uid) references tl_lapixl10_session (uid); +-- Inserting the required config item into the config table +-- Currently supported languages for pixlr +INSERT INTO tl_lapixl10_configuration ( + config_key, + config_value +) +VALUES( + "LanguageCSV", + "en,es,fr,de,it,ru,ro,zh-cn,pt-br,sv,pl,th" +); + + INSERT INTO tl_lapixl10_pixlr ( title, instructions, Index: lams_tool_pixlr/db/sql/drop_lams_tool_pixlr.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/db/sql/drop_lams_tool_pixlr.sql,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/db/sql/drop_lams_tool_pixlr.sql 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/db/sql/drop_lams_tool_pixlr.sql 12 Jan 2009 03:15:39 -0000 1.2 @@ -5,6 +5,7 @@ DROP TABLE IF EXISTS tl_lapixl10_attachment; DROP TABLE IF EXISTS tl_lapixl10_session; DROP TABLE IF EXISTS tl_lapixl10_pixlr; +DROP TABLE IF EXISTS tl_lapixl10_configuration; SET FOREIGN_KEY_CHECKS=1; Index: lams_tool_pixlr/db/sql/table-schema.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/db/sql/table-schema.sql,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/db/sql/table-schema.sql 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/db/sql/table-schema.sql 12 Jan 2009 03:15:39 -0000 1.2 @@ -2,10 +2,12 @@ alter table tl_lapixl10_session drop foreign key FKE5C05E7FCB8ADA74; alter table tl_lapixl10_user drop foreign key FK9A39C08236E23005; drop table if exists tl_lapixl10_attachment; +drop table if exists tl_lapixl10_configuration; drop table if exists tl_lapixl10_pixlr; drop table if exists tl_lapixl10_session; drop table if exists tl_lapixl10_user; create table tl_lapixl10_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, pixlr_uid bigint, primary key (uid)); +create table tl_lapixl10_configuration (uid bigint not null auto_increment, config_key varchar(30) unique, config_value text, primary key (uid)); create table tl_lapixl10_pixlr (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, reflect_on_activity bit, allow_view_others_images bit, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, image_file_name text, image_width bigint, image_height bigint, reflect_instructions text, primary key (uid)); create table tl_lapixl10_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), pixlr_uid bigint, primary key (uid)); create table tl_lapixl10_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, pixlr_session_uid bigint, entry_uid bigint, image_file_name text, imageHeight bigint, imageWidth bigint, imageHidden bit, primary key (uid)); Index: lams_tool_pixlr/db/sql/tool_insert.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/db/sql/tool_insert.sql,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/db/sql/tool_insert.sql 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/db/sql/tool_insert.sql 12 Jan 2009 03:15:39 -0000 1.2 @@ -29,7 +29,8 @@ context_file, create_date_time, modified_date_time, -supports_outputs +supports_outputs, +admin_url ) VALUES ( @@ -60,5 +61,6 @@ '/org/lamsfoundation/lams/tool/pixlr/pixlrApplicationContext.xml', NOW(), NOW(), -0 +0, +'tool/lapixl10/lapixl10admin.do' ) Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/pixlrApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/pixlrApplicationContext.xml,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/pixlrApplicationContext.xml 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/pixlrApplicationContext.xml 12 Jan 2009 03:15:39 -0000 1.2 @@ -26,6 +26,7 @@ org/lamsfoundation/lams/tool/pixlr/model/PixlrSession.hbm.xml org/lamsfoundation/lams/tool/pixlr/model/PixlrUser.hbm.xml org/lamsfoundation/lams/tool/pixlr/model/PixlrAttachment.hbm.xml + org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.hbm.xml @@ -42,6 +43,7 @@ + @@ -95,5 +97,9 @@ + + + + Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/IPixlrConfigItemDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/IPixlrConfigItemDAO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/IPixlrConfigItemDAO.java 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,11 @@ +package org.lamsfoundation.lams.tool.pixlr.dao; + + +import org.lamsfoundation.lams.dao.IBaseDAO; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; + +public interface IPixlrConfigItemDAO extends IBaseDAO +{ + void saveOrUpdate(PixlrConfigItem toConfig); + public PixlrConfigItem getConfigItemByKey(final String configKey); +} Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/hibernate/PixlrConfigItemDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/hibernate/PixlrConfigItemDAO.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/dao/hibernate/PixlrConfigItemDAO.java 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,27 @@ +package org.lamsfoundation.lams.tool.pixlr.dao.hibernate; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.lamsfoundation.lams.dao.hibernate.BaseDAO; +import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrConfigItemDAO; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; +import org.springframework.orm.hibernate3.HibernateCallback; + +public class PixlrConfigItemDAO extends BaseDAO implements IPixlrConfigItemDAO { + private static final String LOAD_CONFIG_ITEM_BY_KEY = "from PixlrConfigItem configuration" + + " where configuration.configKey=:key"; + + public PixlrConfigItem getConfigItemByKey(final String configKey) { + return (PixlrConfigItem) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + return session.createQuery(LOAD_CONFIG_ITEM_BY_KEY).setString("key", configKey).uniqueResult(); + } + }); + + } + + public void saveOrUpdate(PixlrConfigItem mdlForumConfigItem) { + this.getHibernateTemplate().saveOrUpdate(mdlForumConfigItem); + this.getHibernateTemplate().flush(); + } +} Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/model/PixlrConfigItem.java 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,76 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: PixlrConfigItem.java,v 1.1 2009/01/12 03:15:39 lfoxton Exp $ */ +package org.lamsfoundation.lams.tool.pixlr.model; + +/** + * @hibernate.class table="tl_lapixl10_configuration" + */ +public class PixlrConfigItem { + + private static final long serialVersionUID = 930482766653472636L; + + public static final String KEY_LANGUAGE_CSV = "LanguageCSV"; + + Long id; + String configKey; + String configValue; + + public PixlrConfigItem() {} + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * + */ + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + /** + * @hibernate.property column="config_key" length="30" not-null="false" + * unique="true" + */ + public String getConfigKey() { + return configKey; + } + + public void setConfigKey(String configKey) { + this.configKey = configKey; + } + + /** + * @hibernate.property column="config_value" length="511" not-null="false" + */ + public String getConfigValue() { + return configValue; + } + + public void setConfigValue(String configValue) { + this.configValue = configValue; + } + +} Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/IPixlrService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/IPixlrService.java,v diff -u -r1.2 -r1.3 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/IPixlrService.java 8 Jan 2009 00:23:58 -0000 1.2 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/IPixlrService.java 12 Jan 2009 03:15:39 -0000 1.3 @@ -28,6 +28,7 @@ import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.pixlr.model.Pixlr; import org.lamsfoundation.lams.tool.pixlr.model.PixlrAttachment; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; import org.lamsfoundation.lams.tool.pixlr.model.PixlrSession; import org.lamsfoundation.lams.tool.pixlr.model.PixlrUser; import org.lamsfoundation.lams.tool.pixlr.util.PixlrException; @@ -154,11 +155,28 @@ * */ void updateEntry(NotebookEntry notebookEntry); - + /** * Helper method to extract file extension from a string + * * @param fileName * @return */ String getFileExtension(String fileName); + + /** + * Get the pixlr config item by key + * + * @param key + * @return + */ + public PixlrConfigItem getConfigItem(String key); + + /** + * Save a pixlr configItem + * + * @param item + */ + public void saveOrUpdatePixlrConfigItem(PixlrConfigItem item); + } Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java,v diff -u -r1.3 -r1.4 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java 8 Jan 2009 02:39:51 -0000 1.3 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java 12 Jan 2009 03:15:39 -0000 1.4 @@ -66,11 +66,13 @@ import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrAttachmentDAO; +import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrConfigItemDAO; import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrDAO; import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrSessionDAO; import org.lamsfoundation.lams.tool.pixlr.dao.IPixlrUserDAO; import org.lamsfoundation.lams.tool.pixlr.model.Pixlr; import org.lamsfoundation.lams.tool.pixlr.model.PixlrAttachment; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; import org.lamsfoundation.lams.tool.pixlr.model.PixlrSession; import org.lamsfoundation.lams.tool.pixlr.model.PixlrUser; import org.lamsfoundation.lams.tool.pixlr.util.PixlrConstants; @@ -120,6 +122,8 @@ private ICoreNotebookService coreNotebookService; private PixlrOutputFactory pixlrOutputFactory; + + private IPixlrConfigItemDAO pixlrConfigItemDAO; public PixlrService() { super(); @@ -235,15 +239,13 @@ } else { // if cant find or read the file, just copy the default image file if (existingFile.exists() && existingFile.canRead()) { - File existingFile2 = new File(getDefaultContent().getImageFileName()); + File existingFile2 = new File(getDefaultContent().getImageFileName()); String ext = getFileExtension(toContent.getImageFileName()); String newFileName = FileUtil.generateUniqueContentFolderID() + ext; String newFilePath = realBaseDir + File.separator + newFileName; copyFile(existingFile2, newFilePath); return newFileName; - } - else - { + } else { throw new PixlrException("Could not find file to copy"); } } @@ -616,6 +618,14 @@ } } + public PixlrConfigItem getConfigItem(String key) { + return pixlrConfigItemDAO.getConfigItemByKey(key); + } + + public void saveOrUpdatePixlrConfigItem(PixlrConfigItem item) { + pixlrConfigItemDAO.saveOrUpdate(item); + } + /* ===============Methods implemented from ToolContentImport102Manager =============== */ /** @@ -745,4 +755,12 @@ public void setPixlrOutputFactory(PixlrOutputFactory pixlrOutputFactory) { this.pixlrOutputFactory = pixlrOutputFactory; } + + public IPixlrConfigItemDAO getPixlrConfigItemDAO() { + return pixlrConfigItemDAO; + } + + public void setPixlrConfigItemDAO(IPixlrConfigItemDAO pixlrConfigItemDAO) { + this.pixlrConfigItemDAO = pixlrConfigItemDAO; + } } Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/AdminAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/AdminAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/AdminAction.java 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,65 @@ +package org.lamsfoundation.lams.tool.pixlr.web.actions; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; +import org.lamsfoundation.lams.tool.pixlr.service.PixlrServiceProxy; +import org.lamsfoundation.lams.tool.pixlr.service.IPixlrService; +import org.lamsfoundation.lams.tool.pixlr.web.forms.AdminForm; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; + +/** + * @author + * @version + * + * @struts.action path="/lapixl10admin" parameter="dispatch" scope="request" + * name="lapixl10AdminForm" validate="false" + * + * @struts.action-forward name="config" path="/pages/admin/config.jsp" + */ +public class AdminAction extends LamsDispatchAction { + public IPixlrService pixlrService; + + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + // set up mdlForumService + if (pixlrService == null) { + pixlrService = PixlrServiceProxy.getPixlrService(this.getServlet().getServletContext()); + } + + AdminForm adminForm = (AdminForm) form; + + PixlrConfigItem pixlrKey = pixlrService.getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV); + if (pixlrKey != null) + adminForm.setLanguagesCSV(pixlrKey.getConfigValue()); + + request.setAttribute("error", false); + return mapping.findForward("config"); + } + + public ActionForward saveContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + AdminForm adminForm = (AdminForm) form; + + if (adminForm.getLanguagesCSV() != null && !adminForm.getLanguagesCSV().equals("")) { + // set up mdlForumService + if (pixlrService == null) { + pixlrService = PixlrServiceProxy.getPixlrService(this.getServlet().getServletContext()); + } + + PixlrConfigItem pixlrKey = pixlrService.getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV); + pixlrKey.setConfigValue(adminForm.getLanguagesCSV()); + pixlrService.saveOrUpdatePixlrConfigItem(pixlrKey); + + request.setAttribute("savedSuccess", true); + return mapping.findForward("config"); + } else { + request.setAttribute("error", true); + return mapping.findForward("config"); + } + } +} Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/LearningAction.java,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/LearningAction.java 7 Jan 2009 22:37:48 -0000 1.1 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/actions/LearningAction.java 12 Jan 2009 03:15:39 -0000 1.2 @@ -56,6 +56,7 @@ import org.lamsfoundation.lams.tool.pixlr.dto.PixlrDTO; import org.lamsfoundation.lams.tool.pixlr.dto.PixlrUserDTO; import org.lamsfoundation.lams.tool.pixlr.model.Pixlr; +import org.lamsfoundation.lams.tool.pixlr.model.PixlrConfigItem; import org.lamsfoundation.lams.tool.pixlr.model.PixlrSession; import org.lamsfoundation.lams.tool.pixlr.model.PixlrUser; import org.lamsfoundation.lams.tool.pixlr.service.IPixlrService; @@ -91,7 +92,6 @@ private static final boolean MODE_OPTIONAL = false; private static final String PIXLR_UTL = "http://www.pixlr.com/editor/"; - private IPixlrService pixlrService; @@ -183,6 +183,7 @@ String url = PIXLR_UTL + "?"; url += "&title=" + URLEncoder.encode(pixlr.getTitle(), "UTF8"); url += "&referrer=LAMS"; + url += "&loc=" + getPixlrLocale(); String currentImageURL; @@ -452,4 +453,32 @@ request.setAttribute("pixlrImageFolderURL", PixlrConstants.LAMS_WWW_PIXLR_FOLDER_URL); return mapping.findForward("viewAll"); } + + /** + * Work out if this user's language is supported by pixlr + * + * @return + */ + private String getPixlrLocale() { + String locale = "en"; + + String languagesCSV = pixlrService.getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV) != null ? pixlrService + .getConfigItem(PixlrConfigItem.KEY_LANGUAGE_CSV).getConfigValue() : null; + + if (languagesCSV != null && !languagesCSV.equals("")) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + String[] languages = languagesCSV.split(","); + + for (int i = 0; i < languages.length; i++) { + if (languages[i].equals(user.getFckLanguageMapping())) { + locale = languages[i]; + break; + } + } + + } + + return locale; + } } Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/forms/AdminForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/forms/AdminForm.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/web/forms/AdminForm.java 12 Jan 2009 03:15:39 -0000 1.1 @@ -0,0 +1,61 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id: AdminForm.java,v 1.1 2009/01/12 03:15:39 lfoxton Exp $ */ +package org.lamsfoundation.lams.tool.pixlr.web.forms; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; + +/** + * @struts.form name="lapixlr10AdminForm" + */ +public class AdminForm extends ActionForm { + + private static final long serialVersionUID = 378528935723874238L; + + String languagesCSV; + + public AdminForm() { + } + + @Override + public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { + ActionErrors ac = new ActionErrors(); + ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); + return ac; + } + + public String getLanguagesCSV() { + return languagesCSV; + } + + public void setLanguagesCSV(String languagesCSV) { + this.languagesCSV = languagesCSV; + } + +} Index: lams_tool_pixlr/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.1 -r1.2 --- lams_tool_pixlr/web/WEB-INF/struts/struts-config.xml 7 Jan 2009 22:37:49 -0000 1.1 +++ lams_tool_pixlr/web/WEB-INF/struts/struts-config.xml 12 Jan 2009 03:15:39 -0000 1.2 @@ -25,6 +25,10 @@ name="authoringForm" type="org.lamsfoundation.lams.tool.pixlr.web.forms.AuthoringForm" /> + @@ -122,6 +126,21 @@ /> + + + + +<%@ include file="/common/taglibs.jsp"%> + + + + <fmt:message key="pageTitle.admin" /> + + + + + +
+ +

+ +

+ + + +

+ + +

+ +

+ + + +

+ +

+ + + + + + + + + + +
+ + + +
+ + + +

+ + + + + + + + \ No newline at end of file