File: ModifyCat.pm

package info (click to toggle)
sporum 1.8b1-3.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,108 kB
  • ctags: 676
  • sloc: perl: 14,300; makefile: 52
file content (98 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package Templates::Admin::ModifyCat;

use SmallPigVars qw($config);
use SmallPig;
use SPDB;
use CGI qw(:standard :cgi-lib);
use Templates::Admin::StandardIndex;
use Templates::Admin::Block;
use Templates::Admin::OptBlock;
use Templates::Admin::Caution;

use strict;
use vars qw(@ISA);

@ISA = qw(Templates::Admin::Block);

my $lang;

sub new{
  my ($class, $op) = @_;
  
  my $self = Templates::Admin::Block->new("modifycatblock");
  $self->{'op'} = $op;
  $self->{'spdb'} = SPDB->new;

  return bless $self, $class;
}

sub DESTROY{
    my $self = shift;
    my $spdb = $self->{'spdb'};
    $spdb->db_disconnect($spdb->{'dbh'});
}

sub get{
  my ($self, $STATE) = @_;
  my $op = $STATE->{'op'};
  my ($ret, $msg);
  my $theme = $STATE->{'theme'};

  $lang = $STATE->{'langptr'};

  my $content = $self->_get_catlist($STATE, $op);
  my $classvars = {( 'content' => $content)};
  my $catlist = Templates::Admin::OptBlock->new($classvars, $theme);
  my $standardindex = Templates::Admin::StandardIndex->new($STATE);
  
  $msg = $lang->{'modify_cat_msg1'};
  my $caution = Templates::Admin::Caution->new($theme);

  $ret = start_form(-method=>"post", -action=>"$config->{'cgidir'}/admin.cgi");
  $ret .= $standardindex->get();
  $ret .= $caution->get($msg);
  $ret .= $catlist->get();
  $ret .= "<INPUT TYPE=hidden NAME=prev_op VALUE=\"$op\"><font size=1>";
  $ret .= submit(-name=>"op", -value=>$lang->{'ChooseCategory'});
  $ret .= submit(-name=>"op", -value=>$lang->{'RemoveCategory'});
  $ret .= "</font>".end_form();

  return $ret;
}

sub _get_catlist{
  my ($self, $STATE) = @_;
  my $spdb = $self->{'spdb'};
  my $ret;
  
  my $theme = $STATE->{'theme'};

  my ($cats) = $spdb->db_select_many(1, "*", "Cats");

  $ret .= qq!
<TR BGCOLOR=$theme->{'dhdrcolor'} CELLPADDING=2>
<TD WIDTH=10% CLASS=bheader2>$lang->{'select'}</TD>
<TD WIDTH=25% CLASS=bheader2>$lang->{'keyword'}</TD>
<TD WIDTH=75%% CLASS=bheader2>$lang->{'title'}</TD>
</TR>
  !;

  unless($cats){
    $ret .= "<TR><TD COLSPAN=3>$lang->{'no_categories'}</TD></TR>";
  }

  foreach (@$cats){
    my ($catid, $cattitle, $catorder) = @$_;
    
    $ret .= qq!
<TR>
  <TD WIDTH=5%><font size=1><INPUT TYPE=radio NAME=selectedcategory VALUE="$catid"></font></TD>
  <TD WIDTH=10%>$catid</TD>
  <TD WIDTH=19%>$cattitle</TD>
</TR>      
  !;
  }
  return $ret;
}

return 1;