source: trunk/preferences.cgi @ 156

Last change on this file since 156 was 156, checked in by kake, 19 years ago

0.12 14 May 2003

Added OpenGuides::CGI to manage cookies and things, used this to
do more code tidying. Added edit box position option to preferences.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1#!/usr/bin/perl -w
2
3use strict;
4use CGI;
5use Config::Tiny;
6use OpenGuides::CGI;
7use OpenGuides::Utils;
8use OpenGuides::Template;
9
10my $config = Config::Tiny->read("wiki.conf");
11my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
12my $cgi = CGI->new();
13my $action = $cgi->param('action') || '';
14
15if ( $action eq "set_preferences" ) {
16    set_preferences();
17} else {
18    show_form();
19}
20
21exit 0;
22
23sub set_preferences {
24    my $username  = $cgi->param("username") || "";
25    my $gc_link   = $cgi->param('include_geocache_link') || 0;
26    my $pre_above = $cgi->param('preview_above_edit_box') || 0;
27    my $cookie = OpenGuides::CGI->make_prefs_cookie(
28        config => $config,
29        username => $username,
30        include_geocache_link => $gc_link,
31        preview_above_edit_box => $pre_above
32    );
33    print OpenGuides::Template->output(
34        wiki     => $wiki,
35        config   => $config,
36        template => "preferences.tt",
37        cookies  => $cookie,
38        vars     => { not_editable           => 1,
39                      username               => $username,
40                      include_geocache_link  => $gc_link,
41                      preview_above_edit_box => $pre_above
42                    }
43    );
44}
45
46sub show_form {
47    # Get defaults for form fields from cookies.
48    my %prefs = OpenGuides::CGI->get_prefs_from_cookie( config => $config );
49
50    print OpenGuides::Template->output(
51        wiki     => $wiki,
52        config   => $config,
53        template => "preferences.tt",
54        vars     => { %prefs,
55                      not_editable => 1,
56                      show_form    => 1
57                    }
58    );
59}
Note: See TracBrowser for help on using the repository browser.