| 1 | package DBIx::dbMan::Extension::Authors; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'DBIx::dbMan::Extension'; | ||
| 5 | |||
| 6 | our $VERSION = '0.10'; | ||
| 7 | |||
| 8 | # registered authornames | ||
| 9 | our %authorname = ( | ||
| 10 | '000001' => 'Milan Sorm <sorm@is4u.cz>', | ||
| 11 | '000002' => 'Frantisek Darena <darena@mendelu.cz>', | ||
| 12 | '000003' => 'Ales Kutin <kutin@is4u.cz>', | ||
| 13 | '000004' => 'Ondrej \'Kepi\' Kudlik <kepi@igloonet.cz>', | ||
| 14 | '000005' => 'Tomas Klein <klein@is4u.cz>', | ||
| 15 | ); | ||
| 16 | |||
| 17 | 1; | ||
| 18 | |||
| 19 | sub IDENTIFICATION { return "000001-000012-000010"; } | ||
| 20 | |||
| 21 | sub author { return 'Milan Sorm <sorm@is4u.cz>'; } | ||
| 22 | |||
| 23 | sub preference { return 0; } | ||
| 24 | |||
| 25 | sub known_actions { return [ qw/AUTHORS/ ]; } | ||
| 26 | |||
| 27 | sub menu { | ||
| 28 | return ( { label => '_Help', submenu => [ | ||
| 29 | { label => 'Authors', action => { action => 'AUTHORS' } } | ||
| 30 | ] } ); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub handle_action { | ||
| 34 | my ($obj,%action) = @_; | ||
| 35 | |||
| 36 | if ($action{action} eq 'AUTHORS') { | ||
| 37 | my %authors = (); | ||
| 38 | for my $ext (@{$obj->{-core}->{extensions}}) { | ||
| 39 | my $id = $ext->IDENTIFICATION; | ||
| 40 | $id =~ s/-.*//; | ||
| 41 | ++$authors{$id}; | ||
| 42 | if ($ext->can('author')) { | ||
| 43 | $authorname{$id} = $ext->author(); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | my $authors = ''; | ||
| 47 | for (sort { $authors{$a} <=> $authors{$b} } keys %authors) { | ||
| 48 | $authors .= " ".((exists $authorname{$_})?$authorname{$_}:$_)." ($authors{$_} extension".($authors{$_}==1?"":"s").")\n"; | ||
| 49 | } | ||
| 50 | |||
| 51 | $action{output} = "Program:\n ".$authorname{'000001'}."\n\nExtensions:\n".$authors; | ||
| 52 | |||
| 53 | if ($action{gui}) { | ||
| 54 | $action{action} = 'NONE'; | ||
| 55 | $obj->{-interface}->infobox($action{output}); | ||
| 56 | } else { | ||
| 57 | $action{action} = 'OUTPUT'; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | $action{processed} = 1; | ||
| 62 | return %action; | ||
| 63 | } |