~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Plugins/CommentPlugin.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
#
 
3
# See Plugin topic for history and plugin information
 
4
 
 
5
package Foswiki::Plugins::CommentPlugin;
 
6
 
 
7
use strict;
 
8
 
 
9
require Foswiki::Func;
 
10
require Foswiki::Plugins;
 
11
 
 
12
use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $NO_PREFS_IN_TOPIC );
 
13
 
 
14
our $VERSION = '$Rev: 4263 (2009-06-21) $';
 
15
our $RELEASE = '04 Jun 2009';
 
16
our $SHORTDESCRIPTION =
 
17
  'Quickly post comments to a page without an edit/preview/save cycle';
 
18
our $NO_PREFS_IN_TOPIC = 1;
 
19
 
 
20
sub initPlugin {
 
21
    #my ( $topic, $web, $user, $installWeb ) = @_;
 
22
    return 1;
 
23
}
 
24
 
 
25
sub commonTagsHandler {
 
26
    my ( $text, $topic, $web, $meta ) = @_;
 
27
 
 
28
    require Foswiki::Plugins::CommentPlugin::Comment;
 
29
 
 
30
    my $query = Foswiki::Func::getCgiQuery();
 
31
    return unless( defined( $query ) );
 
32
 
 
33
    return unless $_[0] =~ m/%COMMENT({.*?})?%/o;
 
34
 
 
35
    # SMELL: Nasty, tacky way to find out where we were invoked from
 
36
    my $scriptname = $ENV{'SCRIPT_NAME'} || '';
 
37
 
 
38
    # SMELL: unreliable
 
39
    my $previewing = ( $scriptname =~ /\/(preview|gnusave|rdiff|compare)/ );
 
40
    Foswiki::Plugins::CommentPlugin::Comment::prompt( $previewing,
 
41
                                                    $_[0], $web, $topic );
 
42
}
 
43
 
 
44
sub beforeSaveHandler {
 
45
    #my ( $text, $topic, $web ) = @_;
 
46
 
 
47
    require Foswiki::Plugins::CommentPlugin::Comment;
 
48
 
 
49
    my $query = Foswiki::Func::getCgiQuery();
 
50
    return unless $query;
 
51
 
 
52
    my $action = $query->param('comment_action');
 
53
 
 
54
    return unless( defined( $action ) && $action eq 'save' );
 
55
    Foswiki::Plugins::CommentPlugin::Comment::save( @_ );
 
56
}
 
57
 
 
58
1;
 
59
__DATA__
 
60
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
61
#
 
62
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
63
# Foswiki Contributors are listed in the AUTHORS file in the root
 
64
# of this distribution. NOTE: Please extend that file, not this notice.
 
65
#
 
66
# Additional copyrights apply to some or all of the code in this
 
67
# file as follows:
 
68
#
 
69
# Copyright (C) 2001-2006 TWiki Contributors. All Rights Reserved.
 
70
# TWiki Contributors are listed in the AUTHORS file in the root
 
71
# of this distribution. NOTE: Please extend that file, not this notice.
 
72
# Copyright (C) 2004-2008 Crawford Currie
 
73
#
 
74
# This program is free software; you can redistribute it and/or
 
75
# modify it under the terms of the GNU General Public License
 
76
# as published by the Free Software Foundation; either version 2
 
77
# of the License, or (at your option) any later version. For
 
78
# more details read LICENSE in the root of this distribution.
 
79
#
 
80
# This program is distributed in the hope that it will be useful,
 
81
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
82
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.