Index: lams_common/src/flash/org/lamsfoundation/lams/common/dict/Dictionary.as =================================================================== diff -u -r9d5ff613fdf86b299cdebb718f02ecc156be4898 -rd20dcb68643f4f4228f79328027cf370f540e472 --- lams_common/src/flash/org/lamsfoundation/lams/common/dict/Dictionary.as (.../Dictionary.as) (revision 9d5ff613fdf86b299cdebb718f02ecc156be4898) +++ lams_common/src/flash/org/lamsfoundation/lams/common/dict/Dictionary.as (.../Dictionary.as) (revision d20dcb68643f4f4228f79328027cf370f540e472) @@ -1,5 +1,6 @@ import org.lamsfoundation.lams.common.dict.* -import org.lamsfoundation.lams.common.util.* +import org.lamsfoundation.lams.common.util.* +import org.lamsfoundation.lams.common.comms.* /** * Dictionary - Holds all of the LAMS text allowing LAMS to be multilingual @@ -9,28 +10,50 @@ */ dynamic class Dictionary { - private static var items:Hashtable; - private static var loaded:Boolean = false; + private static var items:Hashtable; + private static var loaded:Boolean = false; + private static var usingServer:Boolean; + private static var language:String; /** * @method load * @tooltip Load the dictionary for the language specified * @param language (string) language parameter. * @return */ - public static function load(language:String):Void { - //Only load dictionary once - if(!loaded) { - //Debugger.log('Dictionary-Load',Debugger.GEN,'load','org.lamsfoundation.lams.dict.Dictionary'); - items = new Hashtable(); - //TODO: DI 28/04/05 Load the information for the current language from the server for create items in here - items.put(0,new DictionaryItem(0,'ws_dialog_title','Workspace')); - items.put(1,new DictionaryItem(1,'ws_dialog_ok_button','OK')); - items.put(2,new DictionaryItem(2,'ws_dialog_cancel_button','Cancel')); + public static function load(language:String):Void { + //TODO DI 19/05/05 Check cookie and if not present load from server + //Cookie or server? + /* + if(CookieMonster.cookieExists('Dictionary')) { + //Update flag + usingServer=false; + openFromDisk(); + }else { + //Update flag + usingServer=true; + //openFromServer(); + }*/ - //Set loaded flag - loaded = true; - } + //Only load dictionary once + if(!loaded) { + //store the current language + Dictionary.language = language; + //Debugger.log('Dictionary-Load',Debugger.GEN,'load','org.lamsfoundation.lams.dict.Dictionary'); + items = new Hashtable(); + //TODO: DI 28/04/05 Load the information for the current language from the server for create items in here + //TODO: DI 19/05/05 Implement logic to check locally for language then check server if not found + items.put(0,new DictionaryItem(0,'ws_dialog_title','Workspace')); + items.put(1,new DictionaryItem(1,'ws_dialog_ok_button','OK')); + items.put(2,new DictionaryItem(2,'ws_dialog_cancel_button','Cancel')); + items.put(4,new DictionaryItem(4,'prefs_dialog_title','Preferences')); + items.put(5,new DictionaryItem(5,'prefs_dialog_ok','OK')); + items.put(6,new DictionaryItem(6,'prefs_dialog_cancel','Cancel')); + + //Set loaded flag + loaded = true; + } + } /** @@ -39,5 +62,108 @@ public static function getValue(id:Number):String{ //Debugger.log('returning item-' +id + '-' + items.get(id).value,Debugger.GEN,'getItemById','org.lamsfoundation.lams.dict.Dictionary'); return items.get(id).value; - } + } + + /** + * Converts the dictionary data into a data object ready for serializ + */ + public static function toData():Object{ + var obj:Object ={}; + var hashKeys:Array = items.keys(); + var hashValues:Array = items.values(); + + obj.dictionaryItems = []; + + //Go through hash of dictionary items and get data objects for each + for(var i=0;i