Changeset 306


Ignore:
Timestamp:
Dec 20, 2003, 6:14:22 PM (18 years ago)
Author:
Earle Martin
Message:

Added node deletion functionality to wiki.cgi.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wiki.cgi

    r305 r306  
    1414use CGI::Wiki::Plugin::GeoCache;
    1515use CGI::Wiki::Plugin::Locator::UK;
    16 use CGI::Wiki::Plugin::Diff;
    1716use Config::Tiny;
    1817use Geography::NationalGrid;
     
    2120use OpenGuides::RDF;
    2221use OpenGuides::Utils;
     22use OpenGuides::Diff;
    2323use OpenGuides::Template;
    2424use Time::Piece;
     
    3636$script_url .= "/" unless $script_url =~ /\/$/;
    3737
    38 my ($wiki, $formatter, $locator, $diff_plugin, $q);
     38my ($wiki, $formatter, $locator, $q);
    3939eval {
    4040    $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
     
    4242    $locator = CGI::Wiki::Plugin::Locator::UK->new;
    4343    $wiki->register_plugin( plugin => $locator );
    44     $diff_plugin = CGI::Wiki::Plugin::Diff->new;
    45     $wiki->register_plugin( plugin => $diff_plugin );
    4644
    4745    # Get CGI object, find out what to do.
     
    108106                           origin_param => $formatter->node_name_to_node_param($node),
    109107                           limit  => "$metres metres" } );
     108    } elsif ($action eq 'delete') {
     109        delete_node($node);
    110110    } elsif ($action eq 'userstats') {
    111111        show_userstats( $username );
     
    130130            my $other_ver = $q->param("diffversion");
    131131            if ( $other_ver ) {
    132                 my %diff_vars = $diff_plugin->differences(
    133                     node          => $node,
    134                     left_version  => $version,
    135                     right_version => $other_ver
     132                my %diff_vars = OpenGuides::Diff->formatted_diff_vars(
     133                    wiki     => $wiki,
     134                    node     => $node,
     135                    versions => [ $version, $other_ver ]
    136136                );
    137137                print OpenGuides::Template->output(
     
    188188
    189189        unless ( $wiki->node_exists($node) ) {
    190             warn "Creating default node $node";
    191190            my $category = $type eq "Category" ? "Category" : "Locales";
    192191            $wiki->write_node( $node,
     
    437436}
    438437
     438sub delete_node {
     439    my $node = shift;
     440
     441    my %tt_vars = ( name => $node );
     442
     443    my $password = $q->param('password');
     444
     445    if ($password) {
     446        if ($password ne $config->{_}->{admin_pass}) {
     447            process_template("delete_password_wrong.tt", $node, \%tt_vars)
     448        } else {
     449            $wiki->delete_node($node);
     450            process_template("delete_done.tt", $node, \%tt_vars);
     451        }
     452    } else {
     453        process_template("delete_confirm.tt", $node, \%tt_vars);
     454    }
     455}
     456
    439457sub get_cookie {
    440458    my $pref_name = shift or return "";
Note: See TracChangeset for help on using the changeset viewer.