1 package CXGN
::UserPrefs
::Register
;
5 CXGN::UserPrefs::Register
11 A very simple singleton class which holds a hash of registered user_prefs
12 string id's. In order to create a new user preference id, you must first
13 put the Id in this registry. CXGN::UserPrefs will die if an unregistered
14 preference-setting is attempted.
16 The purpose of the registry is to prevent clobbering of preferences
17 between site developers. Please include a description of your preference
22 # This is the most important part, enter your keys here, or use propose()
23 # to generate the new hash. There is a helper script (propose.pl) in
24 # core/sgn-tools/userprefs that is very useful in generating this hash.
27 "cdsSeqDisp" => "Display boolean",
28 "cdsSpaceSwap" => "Swaps spaces vs no spaces in CDS sequence in Secretary geneview",
29 "genomicSeqDisp" => "",
31 "propertiesCollapse" => "",
32 "proteinInfoCollapse" => "",
34 "searchHighlight" => "Highlighting of search keywords on Secretary",
35 "sp_person_id" => "The owner of the cookie string",
36 "TAIRannotationCollapse" => "",
37 "timestamp" => "Keeps track of preference string age for a user"
42 Given an Id, checks to see if it's in the register, dies otherwise
48 unless(exists $REGISTER{$id}) {
49 die "UserPref ID: '$id' does not exist in the Register. You must enter the key in the \%REGISTER hash of CXGN::UserPrefs::Register.";
55 Given a quoted word list, this will return the text necessary to
56 replace the register hash definition. Conflicts will result in
57 death, with descriptive notices.
66 if(exists $REGISTER{$_}) { push(@exists, $_) }
67 unless(/^[a-zA-Z]\w+$/) { push(@bad_key, $_) }
69 if(@exists or @bad_key) {
70 $failstring = "\nProposal failed.\n";
71 $failstring .= "The key(s) " . join(", ", map { "'$_'" } @exists) . " already exist in the register.\n" if (@exists);
72 $failstring .= "The key(s) " . join(", ", map { "'$_'" } @bad_key) . " are malformed, failed to match /^[a-zA-Z]\\w+\$/" if (@bad_key);
73 $failstring .= "\n\n";
76 my @newkeys = keys %REGISTER;
77 push(@newkeys, @proposed);
78 @newkeys = sort {lc($a) cmp lc($b) } @newkeys;
79 my $newtext = "our \%REGISTER = (\n";
81 foreach my $key (@newkeys) {
82 if(exists $REGISTER{$key}){
83 $newtext .= "\t\"$key\" => \"$REGISTER{$key}\",\n";
86 $newtext .= "\t\"$key\" => \"\",\n";
91 return ($newtext .= "\n);\n");
95 return keys %REGISTER;