/[pub]/suikawiki/script/misc/plugins/referer.wp2
Suika

Diff of /suikawiki/script/misc/plugins/referer.wp2

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Wed Mar 10 06:57:25 2004 UTC revision 1.2 by wakaba, Thu Mar 11 08:06:09 2004 UTC
# Line 68  FormattingRule: Line 68  FormattingRule:
68                       (type => '#element',                       (type => '#element',
69                        namespace_uri => $NS_XHTML1,                        namespace_uri => $NS_XHTML1,
70                        local_name => 'ol');                        local_name => 'ol');
71        for (sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} @list) {        my $default_label = $WIKIRESOURCE->get
         local $o->{iwc__param}->{uri_reference} = URI->new ($_->[0]);  
         my $site = $INTERWIKICORE->get_site_entry_by_uri_reference_match  
                      (o => $o,  
                       page => $o->{wiki}->{config}->{page}->{InterWikiName});  
         $WIKILINKING->to_resource_by_uri_in_html ({  
           label => $WIKIRESOURCE->get  
                       (name => 'Referer:RefererList:Label',  
                        o => $o, wiki => $o->{wiki}),  
           ref__label => (($site ?  
                            $site->get_attribute_value ('URIReference2Label'):'')  
                         || $WIKIRESOURCE->get  
72                               (name => 'Referer:URIReference2Label',                               (name => 'Referer:URIReference2Label',
73                                o => $o, wiki => $o->{wiki})),                                o => $o, wiki => $o->{wiki});
74          my $li_label = $WIKIRESOURCE->get
75                                (name => 'Referer:RefererList:Label',
76                                 o => $o, wiki => $o->{wiki});
77          for my $item (sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} @list) {
78            local $o->{iwc__param}->{uri_reference} = URI->new ($item->[0]);
79            my $label;
80            try {
81              if ($o->{wiki}->{db}->exist (ref__item_template => [$item->[0]])) {
82                $label = $o->{wiki}->{db}->get (ref__item_template => [$item->[0]]);
83              } else {
84                my $site = $INTERWIKICORE->get_site_entry_by_uri_reference_match
85                             (o => $o,
86                              page => $o->{wiki}->{config}->{page}->{InterWikiName});
87                $label = $site ? $site->get_attribute_value ('URIReference2Label')
88                               : $default_label;
89                $o->{wiki}->{db}->set (ref__item_template => [$item->[0]]
90                                                          => $label);
91              }
92            } catch SuikaWiki::DB::Util::Error with {};
93            $WIKILINKING->to_resource_by_uri_in_html ({
94              label => $li_label,
95              ref__label => $label || $default_label,
96          } => {          } => {
97            uri => $o->{iwc__param}->{uri_reference} = URI->new ($_->[0]),            uri => $o->{iwc__param}->{uri_reference},
98          }, {          }, {
99            o => $o,            o => $o,
100            parent => $list->append_new_node            parent => $list->append_new_node
101                       (type => '#element',                       (type => '#element',
102                        namespace_uri => $NS_XHTML1,                        namespace_uri => $NS_XHTML1,
103                        local_name => 'li'),                        local_name => 'li'),
104            ref__weight => $_->[1],            ref__weight => $item->[1],
105          });          });
106        }        }
107      }      }
# Line 100  Function: Line 111  Function:
111    @Main:    @Main:
112      my (undef, %opt) = @_;      my (undef, %opt) = @_;
113      return unless $opt{wiki}->{db};      return unless $opt{wiki}->{db};
114        return unless $opt{uri};
115      $opt{page} ||= $opt{wiki}->{var}->{page};      $opt{page} ||= $opt{wiki}->{var}->{page};
116      my $o = $opt{o} || {wiki => $opt{wiki}};      my $o = $opt{o} || {wiki => $opt{wiki}};
117            
# Line 160  FormattingRule: Line 172  FormattingRule:
172  FormattingRule:  FormattingRule:
173    @Category[list]: link-to-resource    @Category[list]: link-to-resource
174    @Name: ref--referer-item-label    @Name: ref--referer-item-label
175      @Description:
176        @@@:
177          Label for referer list item, that is taken from InterWikiName database.
178        @@lang: en
179    @Formatting:    @Formatting:
180      $f->replace ($o->{link}->{src}->{ref__label},      try {
181                   param => $o,        $f->replace ($o->{link}->{src}->{ref__label},
182                   -parent => $p->{-parent});                     param => $o,
183                       -parent => $p->{-parent});
184        } catch Message::Util::Formatter::error with {
185          my $err = shift;
186          if ($err->{-object}->{-category_name} eq $f->{-category_name}) {
187            my $wiki = $err->{option}->{param}->{wiki};
188            SuikaWiki::Plugin->module_package ('Error')
189                             ->reporting_formatting_template_error
190                                 ($err, $wiki,
191                                  template => $o->{link}->{src}->{ref__label});
192            undef;
193          } else {
194            $err->throw;
195          }
196        };
197    
198  Resource:  Resource:
199    @Referer:RefererList:Label:    @Referer:RefererList:Label:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24