Changeset 824

Show
Ignore:
Timestamp:
08/03/06 15:26:35 (2 years ago)
Author:
nick
Message:

Missing metadata support

Location:
trunk
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r823 r824  
    4343templates/home_node.tt 
    4444templates/map_index.tt 
     45templates/missing_metadata.tt 
    4546templates/navbar.tt 
    4647templates/needing_moderation.tt 
     
    101102t/68_bug_website_displayed.t 
    102103t/70_admin_home.t 
     104t/71_missing_metadata.t 
    103105t/templates/15_test.tt 
    104106wiki.cgi 
  • trunk/lib/OpenGuides.pm

    r822 r824  
    11331133} 
    11341134 
     1135=item B<show_missing_metadata> 
     1136Search for nodes which don't have a certain kind of metadata. Optionally 
     1137also excludes Locales and Categories 
     1138=cut 
     1139sub show_missing_metadata { 
     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    my ($metadata_type, $metadata_value, $exclude_locales, $exclude_categories) 
     1149        = @args{ qw( metadata_type metadata_value exclude_locales exclude_categories ) }; 
     1150 
     1151    my @nodes; 
     1152    my $done_search = 0; 
     1153 
     1154    # Only search if they supplied at least a metadata type 
     1155    if($metadata_type) { 
     1156        $done_search = 1; 
     1157        @nodes = $wiki->list_nodes_by_missing_metadata( 
     1158                            metadata_type => $metadata_type, 
     1159                            metadata_value => $metadata_value, 
     1160                            ignore_case    => 1, 
     1161        ); 
     1162 
     1163        # Do we need to filter some nodes out? 
     1164        if($exclude_locales || $exclude_categories) { 
     1165            my @all_nodes = @nodes; 
     1166            @nodes = (); 
     1167 
     1168            foreach my $node (@all_nodes) { 
     1169                if($exclude_locales && $node =~ /^Locale /) { next; } 
     1170                if($exclude_categories && $node =~ /^Category /) { next; } 
     1171                push @nodes, $node; 
     1172            } 
     1173        } 
     1174    } 
     1175 
     1176    # Build nice edit etc links for our nodes 
     1177    my @tt_nodes; 
     1178    for my $node (@nodes) { 
     1179        my %n; 
     1180 
     1181        # Make the URLs 
     1182        my $node_param = uri_escape( $formatter->node_name_to_node_param( $node ) ); 
     1183 
     1184        # Save into the hash 
     1185        $n{'name'} = $node; 
     1186        $n{'view_url'} = $script_url . "?id=" . $node_param; 
     1187        $n{'edit_url'} = $script_url . "?id=" . $node_param . ";action=edit"; 
     1188        push @tt_nodes, \%n; 
     1189    } 
     1190 
     1191    # Set up our TT variables, including the search parameters 
     1192    my %tt_vars = ( 
     1193                      not_editable  => 1, 
     1194                      not_deletable => 1, 
     1195                      deter_robots  => 1, 
     1196 
     1197                      nodes => \@tt_nodes, 
     1198                      done_search    => $done_search, 
     1199                      metadata_type  => $metadata_type, 
     1200                      metadata_value => $metadata_value, 
     1201                      exclude_locales => $exclude_locales, 
     1202                      exclude_categories => $exclude_categories 
     1203                  ); 
     1204    return %tt_vars if $return_tt_vars; 
     1205 
     1206    # Render to the page 
     1207    my $output = $self->process_template( 
     1208                                           id       => "", 
     1209                                           template => "missing_metadata.tt", 
     1210                                           tt_vars  => \%tt_vars, 
     1211                                        ); 
     1212    return $output if $return_output; 
     1213    print $output; 
     1214} 
     1215 
    11351216=item B<display_admin_interface> 
    11361217Fetch everything we need to display the admin interface, and passes it off  
  • trunk/templates/admin_home.tt

    r822 r824  
    99        <li><a href="#locales">Locales</a></li> 
    1010        <li><a href="#categories">Categories</a></li> 
     11        <li><a href="?action=show_needing_moderation">Pages Needing Moderation</a> 
     12        <li><a href="?action=show_missing_metadata">Pages Missing Metadata</a> 
    1113</ul> 
    1214 
  • trunk/wiki.cgi

    r821 r824  
    8585    } elsif ( $action eq 'admin' ) { 
    8686        $guide->display_admin_interface(); 
     87    } elsif ( $action eq 'show_missing_metadata' ) { 
     88        $guide->show_missing_metadata( 
     89                             metadata_type  => $q->param("metadata_type"), 
     90                             metadata_value => $q->param("metadata_value"), 
     91                             exclude_locales => $q->param("exclude_locales"), 
     92                             exclude_categories => $q->param("exclude_categories") 
     93        ); 
    8794    } elsif ( $action eq 'set_moderation' ) { 
    8895        $guide->set_node_moderation(