Changeset 1084
- Timestamp:
- 06/16/07 22:33:16 (16 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
lib/OpenGuides/CGI.pm (modified) (1 diff)
-
preferences.cgi (modified) (3 diffs)
-
templates/preferences.tt (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/OpenGuides/CGI.pm
r992 r1084 156 156 %data = $cookies{$cookie_name}->value; # call ->value in list context 157 157 } 158 159 return $class->get_prefs_from_hash( %data ); 160 } 161 162 sub get_prefs_from_hash { 163 my ($class, %data) = @_; 158 164 my %defaults = ( 159 165 username => "Anonymous", -
trunk/preferences.cgi
r752 r1084 23 23 24 24 sub set_preferences { 25 my $username = $cgi->param("username") || ""; 26 my $gc_link = $cgi->param("include_geocache_link") || 0; 27 my $pre_above = $cgi->param("preview_above_edit_box") || 0; 28 my $latlong_trad = $cgi->param("latlong_traditional") || 0; 29 my $omit_hlplnks = $cgi->param("omit_help_links") || 0; 30 my $rc_minor_eds = $cgi->param("show_minor_edits_in_rc") || 0; 31 my $edit_type = $cgi->param("default_edit_type") || "normal"; 32 my $expires = $cgi->param("cookie_expires") || "month"; 33 my $track_rc = $cgi->param("track_recent_changes_views") || 0; 34 my $gmaps = $cgi->param("display_google_maps") || 0; 25 my %prefs = OpenGuides::CGI->get_prefs_from_hash( $cgi->Vars ); 35 26 my $prefs_cookie = OpenGuides::CGI->make_prefs_cookie( 36 27 config => $config, 37 username => $username, 38 include_geocache_link => $gc_link, 39 preview_above_edit_box => $pre_above, 40 latlong_traditional => $latlong_trad, 41 omit_help_links => $omit_hlplnks, 42 show_minor_edits_in_rc => $rc_minor_eds, 43 default_edit_type => $edit_type, 44 cookie_expires => $expires, 45 track_recent_changes_views => $track_rc, 46 display_google_maps => $gmaps 28 %prefs, 47 29 ); 48 30 my @cookies = ( $prefs_cookie ); … … 63 45 vars => { 64 46 not_editable => 1, 65 username => $username, 66 include_geocache_link => $gc_link, 67 preview_above_edit_box => $pre_above, 68 latlong_traditional => $latlong_trad, 69 omit_help_links => $omit_hlplnks, 70 show_minor_edits_in_rc => $rc_minor_eds, 71 default_edit_type => $edit_type, 72 cookie_expires => $expires, 73 track_recent_changes_views => $track_rc, 74 display_google_maps => $gmaps 47 %prefs, 75 48 } 76 49 ); … … 78 51 79 52 sub show_form { 80 # Get defaults for form fields from cookies.81 my %prefs = OpenGuides::CGI->get_prefs_from_cookie( config => $config );82 83 53 print OpenGuides::Template->output( 84 54 wiki => $wiki, 85 55 config => $config, 86 56 template => "preferences.tt", 87 vars => { %prefs,57 vars => { 88 58 not_editable => 1, 89 59 show_form => 1 -
trunk/templates/preferences.tt
r1053 r1084 14 14 15 15 <p> 16 [% IF pre view_above_edit_box %]16 [% IF prefs.preview_above_edit_box %] 17 17 <input type="checkbox" id="preview_above" name="preview_above_edit_box" value="1" checked /> 18 18 [% ELSE %] … … 23 23 24 24 <p> 25 [% IF include_geocache_link %]25 [% IF prefs.include_geocache_link %] 26 26 <input type="checkbox" id="geocache" name="include_geocache_link" value="1" checked /> 27 27 [% ELSE %] … … 32 32 33 33 <p> 34 [% IF latlong_traditional %]34 [% IF prefs.latlong_traditional %] 35 35 <input type="checkbox" id="latlong" name="latlong_traditional" value="1" checked /> 36 36 [% ELSE %] … … 41 41 42 42 <p> 43 [% IF omit_help_links %]43 [% IF prefs.omit_help_links %] 44 44 <input type="checkbox" id="omit_help" name="omit_help_links" value="1" checked /> 45 45 [% ELSE %] … … 50 50 51 51 <p> 52 [% IF show_minor_edits_in_rc %]52 [% IF prefs.show_minor_edits_in_rc %] 53 53 <input type="checkbox" id="show_minor" name="show_minor_edits_in_rc" value="1" checked /> 54 54 [% ELSE %] … … 59 59 60 60 <p> 61 [% IF track_recent_changes_views %]61 [% IF prefs.track_recent_changes_views %] 62 62 <input type="checkbox" id="track_recent_changes_views" name="track_recent_changes_views" value="1" checked="1" /> 63 63 [% ELSE %] … … 69 69 [% IF gmaps_api_key AND config.show_gmap_in_node_display %] 70 70 <p> 71 [% IF display_google_maps %]71 [% IF prefs.display_google_maps %] 72 72 <input type="checkbox" id="display_google_maps" name="display_google_maps" value="1" checked="1" /> 73 73 [% ELSE %] … … 81 81 <label for="default_edit_type">Default edit type:</label> 82 82 <select name="default_edit_type" id="default_edit_type"> 83 [% IF default_edit_type == 'normal' %]83 [% IF prefs.default_edit_type == 'normal' %] 84 84 <option value="normal" selected="1">Normal edit</option> 85 85 <option value="tidying">Minor tidying</option> … … 94 94 <label for="cookie_expires">Preferences expire:</label> 95 95 <select name="cookie_expires" id="cookie_expires"> 96 [% IF cookie_expires == 'never' %]96 [% IF prefs.cookie_expires == 'never' %] 97 97 <option value="month">in one month</option> 98 98 <option value="year">in one year</option> 99 99 <option value="never" selected="1">never</option> 100 [% ELSIF cookie_expires == "year" %]100 [% ELSIF prefs.cookie_expires == "year" %] 101 101 <option value="month">in one month</option> 102 102 <option value="year" selected="1">in one year</option> … … 121 121 122 122 <p>Preview area shown 123 [% IF pre view_above_edit_box %]123 [% IF prefs.preview_above_edit_box %] 124 124 above 125 125 [% ELSE %] … … 133 133 134 134 <p>Latitude and longitude displayed as 135 [% IF latlong_traditional %]135 [% IF prefs.latlong_traditional %] 136 136 degrees and minutes. 137 137 [% ELSE %] … … 141 141 142 142 <p>Help links will 143 [% IF omit_help_links %] not [% END %]143 [% IF prefs.omit_help_links %] not [% END %] 144 144 be included in navbar. 145 145 </p> … … 153 153 be tracked.</p> 154 154 155 [% IF gmaps_api_key AND config.show_gmap_in_node_display %]155 [% IF prefs.gmaps_api_key AND config.show_gmap_in_node_display %] 156 156 <p>Google Maps will 157 157 [% UNLESS display_google_maps %] not [% END %] … … 160 160 161 161 <p>Default edit type set to 162 [% IF default_edit_type == 'normal' %]162 [% IF prefs.default_edit_type == 'normal' %] 163 163 “Normal edit”. 164 164 [% ELSE %] … … 168 168 169 169 <p>Your preferences will 170 [% IF cookie_expires == 'never' %]170 [% IF prefs.cookie_expires == 'never' %] 171 171 never expire. 172 [% ELSIF cookie_expires == 'year' %]172 [% ELSIF prefs.cookie_expires == 'year' %] 173 173 expire in one year. 174 174 [% ELSE %]
