Ignore:
Timestamp:
11/19/08 15:00:00 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: port a subset of the standard extensions over to the new namespace to make a working system with mixed TWiki and Foswiki plugins

Location:
trunk/CommentPlugin/lib/Foswiki
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/CommentPlugin/lib/Foswiki/Plugins/CommentPlugin/Comment.pm

    r781 r811  
    22# 
    33# Copyright (C) 2004 Crawford Currie 
    4 # Copyright (C) 2001-2006 TWiki Contributors. 
    5 # All Rights Reserved. TWiki Contributors 
     4# Copyright (C) 2001-2006 Foswiki Contributors. 
     5# All Rights Reserved. Foswiki Contributors 
    66# are listed in the AUTHORS file in the root of this distribution. 
    77# NOTE: Please extend that file, not this notice. 
     
    2323# and again by Crawford Currie 
    2424# 
    25 # This version is specific to TWiki::Plugins::VERSION > 1.026 
     25# This version is specific to Foswiki::Plugins::VERSION > 1.026 
    2626 
    2727use strict; 
    2828 
    29 use TWiki; 
    30 use TWiki::Plugins; 
    31 use TWiki::Store; 
    32 use TWiki::Attrs; 
     29use Foswiki; 
     30use Foswiki::Plugins; 
     31use Foswiki::Store; 
     32use Foswiki::Attrs; 
    3333use CGI qw( -any ); 
    3434 
    35 package TWiki::Plugins::CommentPlugin::Comment; 
     35package Foswiki::Plugins::CommentPlugin::Comment; 
    3636 
    3737# PUBLIC save the given comment. 
     
    3939    #my ( $text, $topic, $web ) = @_; 
    4040 
    41     my $wikiName = TWiki::Func::getWikiName(); 
    42     if( ! TWiki::Func::checkAccessPermission( 'change', $wikiName, '', 
     41    my $wikiName = Foswiki::Func::getWikiName(); 
     42    if( ! Foswiki::Func::checkAccessPermission( 'change', $wikiName, '', 
    4343                                                                                          $_[1], $_[2] ) ) { 
    4444        # user has no permission to change the topic 
    45         throw TWiki::OopsException( 'accessdenied', 
     45        throw Foswiki::OopsException( 'accessdenied', 
    4646                                    def => 'topic_access', 
    4747                                    web => $_[2], 
     
    5656    #my ( $previewing, $text, $web, $topic ) = @_; 
    5757 
    58     my $defaultType = TWiki::Func::getPreferencesValue('COMMENTPLUGIN_DEFAULT_TYPE') || 'above'; 
     58    my $defaultType = Foswiki::Func::getPreferencesValue('COMMENTPLUGIN_DEFAULT_TYPE') || 'above'; 
    5959 
    6060    my $message = ''; 
     
    8484    if ( $attrtemplatetopic ) { 
    8585        my ($templocweb, $temploctopic ) = 
    86           TWiki::Func::normalizeWebTopicName($templateweb, $attrtemplatetopic); 
     86          Foswiki::Func::normalizeWebTopicName($templateweb, $attrtemplatetopic); 
    8787        $templatetopic = "$templocweb.$temploctopic"; 
    8888    } 
     
    9797    $attributes =~ s/^{(.*)}$/$1/ if ( $attributes ); 
    9898 
    99     my $attrs = new TWiki::Attrs( $attributes, 1 ); 
     99    my $attrs = new Foswiki::Attrs( $attributes, 1 ); 
    100100    my $type = 
    101101      $attrs->remove( 'type' ) || $attrs->remove( 'mode' ) || $defaultType; 
     
    143143    my $url = ''; 
    144144    if ( $disable eq '' ) { 
    145         $url = TWiki::Func::getScriptUrl( $web, $topic, 'save' ); 
     145        $url = Foswiki::Func::getScriptUrl( $web, $topic, 'save' ); 
    146146    } 
    147147 
     
    213213    # Get the templates. 
    214214    my $templateFile = $templatetopic 
    215         || TWiki::Func::getPreferencesValue('COMMENTPLUGIN_TEMPLATES') 
     215        || Foswiki::Func::getPreferencesValue('COMMENTPLUGIN_TEMPLATES') 
    216216        || 'comments'; 
    217217 
    218218    my $templates = 
    219       TWiki::Func::loadTemplate( $templateFile ); 
     219      Foswiki::Func::loadTemplate( $templateFile ); 
    220220    if (! $templates ) { 
    221         TWiki::Func::writeWarning("Could not read template file '$templateFile'"); 
     221        Foswiki::Func::writeWarning("Could not read template file '$templateFile'"); 
    222222        return; 
    223223    } 
    224224 
    225     my $t = TWiki::Func::expandTemplate( $name ); 
     225    my $t = Foswiki::Func::expandTemplate( $name ); 
    226226    return "%RED%No such template def TMPL:DEF{$name}%ENDCOLOR%" 
    227227      unless ( defined($t) && $t ne '' ) || $warn eq 'off'; 
     
    244244    my ( $topic, $web ) = ( $_[1], $_[2] ); 
    245245 
    246     my $query = TWiki::Func::getCgiQuery(); 
     246    my $query = Foswiki::Func::getCgiQuery(); 
    247247    return unless $query; 
    248248 
    249249    my $type = $query->param( 'comment_type' ) || 
    250       TWiki::Func::getPreferencesValue('COMMENTPLUGIN_DEFAULT_TYPE') || 
     250      Foswiki::Func::getPreferencesValue('COMMENTPLUGIN_DEFAULT_TYPE') || 
    251251          'below'; 
    252252    my $index = $query->param( 'comment_index' ) || 0; 
     
    270270    # Expand common variables in the template, but don't expand other 
    271271    # tags. 
    272     $output = TWiki::Func::expandVariablesOnTopicCreation($output); 
     272    $output = Foswiki::Func::expandVariablesOnTopicCreation($output); 
    273273 
    274274    $output = '' unless defined($output); 
Note: See TracChangeset for help on using the changeset viewer.