Changeset 1048


Ignore:
Timestamp:
11/28/08 18:05:15 (3 years ago)
Author:
CrawfordCurrie
Message:

Item175: fix web names for presentation in InstalledPlugins/Plugins

Location:
trunk/core/lib/Foswiki
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/lib/Foswiki/Plugin.pm

    r1041 r1048  
    115115 
    116116    undef $this->{name}; 
    117     undef $this->{installWeb}; 
     117    undef $this->{topicWeb}; 
    118118    undef $this->{module}; 
    119119    undef $this->{errors}; 
     
    129129    my ($this) = @_; 
    130130    my $p = $Foswiki::cfg{Plugins}{$this->{name}}{Module}; 
    131     $this->{installWeb} = $Foswiki::cfg{SystemWebName}; 
    132131 
    133132    if (defined $p) { 
     
    150149    my $noTopic = eval '$' . $p . '::NO_PREFS_IN_TOPIC'; 
    151150    $this->{no_topic} = $noTopic; 
    152     $this->{installWeb} = undef; # not known yet 
    153  
    154     # Find the plugin topic, if required 
    155     if ($noTopic) { 
    156         $this->{installWeb} = $Foswiki::cfg{SystemWebName}; 
    157     } else  { 
    158         my $store = $this->{session}->{store}; 
    159  
    160         foreach my $web (split(/[, ]+/, 
    161                                $Foswiki::cfg{Plugins}{WebSearchPath}), 
    162                          $this->{session}->{webName}) { 
    163             if ( $store->topicExists( $web, $this->{name} ) ) { 
    164                 $this->{installWeb} = $web; 
    165                 last; 
    166             } 
    167         } 
    168         if (!$this->{installWeb}) { 
     151    $this->{topicWeb} = undef; # not known yet 
     152 
     153    unless ($noTopic) { 
     154        if (!$this->topicWeb()) { 
    169155            # not found 
    170156            push( 
     
    175161            ); 
    176162            $noTopic = 1; 
    177             $this->{installWeb} = $Foswiki::cfg{SystemWebName}; 
    178163        } 
    179164    } 
     
    230215    my $prefs = $this->{session}->{prefs}; 
    231216    if ( !$this->{no_topic} ) { 
    232         $prefs->pushPreferences( $this->{installWeb}, $this->{name}, 'PLUGIN', 
     217        $prefs->pushPreferences( $this->{topicWeb}, $this->{name}, 'PLUGIN', 
    233218            uc( $this->{name} ) . '_' ); 
    234219    } 
     
    249234        $Foswiki::Plugins::SESSION->{webName}, 
    250235        $users->getLoginName( $Foswiki::Plugins::SESSION->{user} ), 
    251         $this->{installWeb} 
     236        $this->{topicWeb} 
    252237    ); 
    253238    use strict 'refs'; 
     
    329314    $version = $release . ', ' . $version if $release; 
    330315 
    331     my $result = ' ' . $this->{installWeb} . '.' . $this->{name} . ' '; 
     316    my $web = $this->topicWeb(); 
     317    my $result = ' ' . ($web ? "$web." : '!') . $this->{name} . ' '; 
    332318    $result .= 
    333319      CGI::span( { class => 'twikiGrayText twikiSmall' }, 
     
    337323} 
    338324 
     325=begin TML 
     326 
     327---++ ObjectMethod topicWeb() -> $webname 
     328 
     329Find the web that has the topic for this plugin by searching the 
     330{Plugins}{WebSearchPath} 
     331 
     332=cut 
     333 
     334sub topicWeb { 
     335    my $this = shift; 
     336 
     337    unless ( $this->{topicWeb}) { 
     338        # Find the plugin topic, if required 
     339        my $store = $this->{session}->{store}; 
     340 
     341        foreach my $web (split(/[, ]+/, 
     342                               $Foswiki::cfg{Plugins}{WebSearchPath}), 
     343                         $this->{session}->{webName}) { 
     344            if ( $store->topicExists( $web, $this->{name} ) ) { 
     345                $this->{topicWeb} = $web; 
     346                last; 
     347            } 
     348        } 
     349    } 
     350    return $this->{topicWeb}; 
     351} 
     352 
    3393531; 
  • trunk/core/lib/Foswiki/Plugins.pm

    r1041 r1048  
    393393            $td = CGI::td('none'); 
    394394        } 
    395 die "BALLS $plugin->{name}" unless $plugin->{installWeb}; 
     395        my $web = $plugin->topicWeb(); 
    396396        $text .= CGI::Tr( 
    397397            { valign => 'top' }, 
    398398            CGI::td( 
    399                 ' ' . $plugin->{installWeb} . '.' . $plugin->{name} . ' ' 
     399                ' ' . ($web ? "$web." : '!').$plugin->{name}.' ' 
    400400              ) 
    401401              . $td 
Note: See TracChangeset for help on using the changeset viewer.