Changeset 822

Show
Ignore:
Timestamp:
07/27/06 18:13:52 (2 years ago)
Author:
nick
Message:

Start on the admin interface

Location:
trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r821 r822  
    2828preferences.cgi 
    2929search.cgi 
     30templates/admin_home.tt 
    3031templates/backlink_results.tt 
    3132templates/banner.tt 
  • trunk/lib/OpenGuides.pm

    r820 r822  
    11331133} 
    11341134 
     1135=item B<display_admin_interface> 
     1136Fetch everything we need to display the admin interface, and passes it off  
     1137 to the template 
     1138=cut 
     1139sub display_admin_interface { 
     1140    my ($self, %args) = @_; 
     1141    my $return_tt_vars = $args{return_tt_vars} || 0; 
     1142    my $return_output = $args{return_output} || 0; 
     1143 
     1144    my $wiki = $self->wiki; 
     1145    my $formatter = $self->wiki->formatter; 
     1146    my $script_url = $self->config->script_url; 
     1147 
     1148    # Grab all the nodes 
     1149    my @all_nodes = $wiki->list_all_nodes(with_details=>1); 
     1150    @all_nodes = sort { $a->{'name'} cmp $b->{'name'} } @all_nodes; 
     1151 
     1152 
     1153    # Split into nodes, Locales and Categories 
     1154    my @nodes; 
     1155    my @categories; 
     1156    my @locales; 
     1157    for my $node (@all_nodes) { 
     1158        # Make the URLs 
     1159        my $node_param = uri_escape( $formatter->node_name_to_node_param( $node->{'name'} ) ); 
     1160        $node->{'view_url'} = $script_url . "?id=" . $node_param; 
     1161        $node->{'versions_url'} = $script_url . "?action=list_all_versions;id=" . $node_param; 
     1162        $node->{'moderation_url'} = $script_url . "?action=set_moderation;id=" . $node_param; 
     1163 
     1164        # Filter 
     1165        if($node->{'name'} =~ /^Category /) { 
     1166            $node->{'page_name'} = $node->{'name'}; 
     1167            $node->{'name'} =~ s/^Category //; 
     1168            push @categories, $node; 
     1169        } elsif($node->{'name'} =~ /^Locale /) { 
     1170            $node->{'page_name'} = $node->{'name'}; 
     1171            $node->{'name'} =~ s/^Locale //; 
     1172            push @locales, $node; 
     1173        } else { 
     1174            push @nodes, $node; 
     1175        } 
     1176    } 
     1177 
     1178    # Render in a template 
     1179    my %tt_vars = ( 
     1180                      not_editable  => 1, 
     1181                      not_deletable => 1, 
     1182                      deter_robots  => 1, 
     1183                      nodes => \@nodes, 
     1184                      categories => \@categories, 
     1185                      locales => \@locales 
     1186                  ); 
     1187    return %tt_vars if $return_tt_vars; 
     1188    my $output = $self->process_template( 
     1189                                           id       => "", 
     1190                                           template => "admin_home.tt", 
     1191                                           tt_vars  => \%tt_vars, 
     1192                                        ); 
     1193    return $output if $return_output; 
     1194    print $output; 
     1195} 
     1196 
    11351197sub process_template { 
    11361198    my ($self, %args) = @_;