]> ruin.nu Git - ndwebbie.git/blob - ND/Web/Pages/Settings.pm
possible to chose stylesheet
[ndwebbie.git] / ND / Web / Pages / Settings.pm
1 #**************************************************************************
2 #   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
3 #                                                                         *
4 #   This program is free software; you can redistribute it and/or modify  *
5 #   it under the terms of the GNU General Public License as published by  *
6 #   the Free Software Foundation; either version 2 of the License, or     *
7 #   (at your option) any later version.                                   *
8 #                                                                         *
9 #   This program is distributed in the hope that it will be useful,       *
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 #   GNU General Public License for more details.                          *
13 #                                                                         *
14 #   You should have received a copy of the GNU General Public License     *
15 #   along with this program; if not, write to the                         *
16 #   Free Software Foundation, Inc.,                                       *
17 #   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
18 #**************************************************************************/
19
20 package ND::Web::Pages::Settings;
21 use strict;
22 use warnings FATAL => 'all';
23 use ND::Include;
24 use CGI qw/:standard/;
25 use ND::Web::Include;
26
27 $ND::PAGES{settings} = {parse => \&parse, process => \&process, render=> \&render};
28
29 sub parse {
30         my ($uri) = @_;
31 }
32
33 sub process {
34
35 }
36
37 sub render {
38         my ($DBH,$BODY) = @_;
39
40         $ND::TEMPLATE->param(TITLE => 'Edit site preferences');
41
42         if (defined param 'cmd'){
43                 if(param('cmd') eq 'stylesheet'){
44                         my $query = $DBH->prepare(q{UPDATE users SET css = NULLIF($2,'') WHERE uid = $1});
45                         $query->execute($ND::UID,escapeHTML(param 'stylesheet')) or $ND::ERROR .= p $DBH->errstr;
46                 }
47         }
48         my ($css) = $DBH->selectrow_array(q{SELECT css FROM users WHERE uid = $1},undef,$ND::UID);
49         my @stylesheets = ({Style => ''});
50         $css = '' unless defined $css;
51         while (<stylesheets/*.css>){
52                 if(m{stylesheets/(\w+)\.css}){
53                         push @stylesheets,{Style => $1, Selected => $1 eq $css ? 1 : 0};
54                 }
55         }
56         $BODY->param(StyleSheets => \@stylesheets);
57         return $BODY;
58 }
59
60 1;