<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package LinuxFocus::DB;

use strict;
use vars qw ( $VERSION @ISA @EXPORT_OK );
use XML::DOM;

BEGIN {
  require XML::DOM;

  $VERSION = '0.7';      # 2000-09-07

  @ISA         = qw( Exporter );
  @EXPORT_OK   = qw( &amp;load );

  return 1;
}

sub new {
  my ($class, %args) = @_;

  $args{DOMparser_args} ||= {'KeepCDATA' =&gt; 1}; # Default #
  $args{debug} ||= 1;         # False if undef #
  $args{indent} ||= 0;         # Default to 0   #
  $args{indent_incr} ||= 1;    # Default to 1   #

  my $parser = bless { DOMparser =&gt; XML::DOM::Parser-&gt;new (),
                       DOMparser_args =&gt; $args{DOMparser_args},
	               variables =&gt; \%args,
		       debug =&gt; $args{debug},
                       doc =&gt; undef,
                       article =&gt; undef,
                       lang =&gt; "en",
                       articleid =&gt; undef
		     }, $class;
  return $parser;
}

sub load {
    my ($class, $file, @dummy) = @_;  

    my $parser = new XML::DOM::Parser;
    die "$file not found!\n" if (!(-e $file));
    $class-&gt;{doc} = $parser-&gt;parsefile ($file);
}

sub getDBLang {
    my ($class, @dummy) = @_;
    die "Database not loaded!\n" if (!defined $class-&gt;{doc});
    
    my @root = $class-&gt;{doc}-&gt;getElementsByTagName("database");
    my $result = ($root[0])-&gt;getAttribute("xml:lang");
    $result = ($root[0])-&gt;getAttribute("name") if ($result eq "");
    if (!defined $result) {
        $result = $class-&gt;{lang};
    }
    return $result;
}

sub setLang {
    my $class = shift @_;
    $class-&gt;{lang} = shift @_;
} 

sub toString {
    my ($class, @dummy) = @_;
    return $class-&gt;{doc}-&gt;toString();
}

sub getCurrentMonthID {
    my ($class, %args) = @_;

    my $result = "May2000";
    my $resultcode = "200005";
    foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("issue")) { 
        my $id = $kid-&gt;getAttribute("id");
        my $code = $kid-&gt;getAttribute("code");
        #print STDERR "DEBUG: $id, $code ($resultcode)$/" if ($id ne "");
        #print STDERR " is greater!!!$/" if ($code gt $resultcode);
        #print STDERR " is published!!!$/" if (issueIsPublished($class, $id));
        if (($id ne "") &amp;&amp; ($code ne "") &amp;&amp; ($code &gt; $resultcode) &amp;&amp;
            issueIsPublished($class, $id)) {
            $resultcode = $code;
            $result = $kid-&gt;getAttribute("id");
	}
    }
    return ($result, $resultcode);
}

sub getMonthIDs {
    my ($class, %args) = @_;
    my ($sort, $limit);
    if (%args) {
      $sort = $args{"sort"};
      $limit = $args{"limit"};
    }
    my $raw       = $args{"raw"} || "no";

    my %temp = ();
    my @result = ();
    foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("issue")) { 
        if ($kid-&gt;getAttribute("id") ne "" &amp;&amp;
            $kid-&gt;getAttribute("code") ne "") {
            $temp{$kid-&gt;getAttribute("code")} = $kid-&gt;getAttribute("id");
        }
    }

    my @keys = keys %temp;
    if (defined $sort) {
        @keys = sort @keys;
        if ($sort eq "asc") {
        } else {
            # assume descending order
            @keys = reverse @keys;
        }
    } else {
        # assume random order is oke
    }
    my $counter = 0;
    foreach my $key (@keys) {
        $counter++;
        if ((!defined $limit) || $counter &lt;= $limit) {
            if ($raw eq "yes") {
                push(@result, $key . "{" . $temp{$key});
            } else {
                push(@result, $temp{$key});
	    }
        }
    }
    return @result;
}

sub getPersonIDs {
    my ($class, %args) = @_;
    my ($team, $sort, $limit);
    if (%args) {
	$team = $args{"team"};
        $sort = $args{"sort"};
        $limit = $args{"limit"};
    }
    my $raw       = $args{"raw"} || "no";

    my %temp = ();
    my @result = ();
    foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("person")) { 
        if ($kid-&gt;getAttribute("id") ne "") {
            my @teams = $kid-&gt;getElementsByTagName("team");
   	    if (defined $teams[0]) {
                if ($teams[0]-&gt;getAttribute("xml:lang") eq $team) {
                    $temp{getPersonName($class, $kid-&gt;getAttribute("id"))} = 
                        $kid-&gt;getAttribute("id");
                }
            } 
        }
    }

    my @keys = keys %temp;
    if (defined $sort) {
        @keys = sort @keys;
        if ($sort eq "asc") {
        } else {
            # assume descending order
            @keys = reverse @keys;
        }
    } else {
        # assume random order is oke
    }
    my $counter = 0;
    foreach my $key (@keys) {
        $counter++;
        if ((!defined $limit) || $counter &lt;= $limit) {
            if ($raw eq "yes") {
                push(@result, $key . "{" . $temp{$key});
            } else {
                push(@result, $temp{$key});
	    }
        }
    }
    return @result;
}

sub getArticleIDs {
    my ($class, %args) = @_;
    my ($month, $translated, $to, $from); 
    my $limit;
    if (%args) {
      # Use month =&gt; "" to get IDs of article in a certain month
      $month = $args{"month"};

      # Use translated =&gt; "yes" with either/both to =&gt; "" or/and
      #   from =&gt; "" to select tranlated articles
      $translated = $args{"translated"};
      $to = $args{"to"};
      $from = $args{"from"};
      
      # general variables
      $limit = $args{"limit"};
    }
    my $sort      = $args{"sort"} || "no";
    my $published = $args{"published"} || "no";
    my $cover     = $args{"coverpages"} || "no";
    my $raw       = $args{"raw"} || "no";

    my %temp = ();
    if (defined $month) {
        foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("article")) {
            my $id = $kid-&gt;getAttribute("id");
            selectArticle($class, $id);
            if (getArticleMonthID($class) eq $month) {
                $temp{$id} = $id;
	    }
        }
    } elsif (defined $translated &amp;&amp; (defined $to || defined $from)) {
        foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("article")) { 
            my $id = $kid-&gt;getAttribute("id");
            selectArticle($class, $id);
            my $date = "";
            if (defined $to || !defined $from) {
                $date = getArticleTranslationDate($class, to =&gt; "$to") || "";
            } elsif (defined $from) {
                $date = getArticleTranslationDate($class, from =&gt; "$from") || "";
	    } else {
                $date = getArticleTranslationDate($class, from =&gt; "$from",
                                                  to   =&gt; "$to") || "";
	    }
            if ($date ne "") {
       	        $temp{"$date$id"} = $id;
	    }
        }
    } else {
        foreach my $kid ($class-&gt;{doc}-&gt;getElementsByTagName("article")) { 
   	     my $id = $kid-&gt;getAttribute("id");
             $temp{$id} = $id;
        }
    }

    my @result = ();
    my @keys = keys %temp;
    if ($sort ne "no") {
        @keys = sort @keys;
        if ($sort eq "desc") {
            @keys = reverse @keys;
        }
    }
    my $counter = 0;
    foreach my $key (@keys) {
        if ((!defined $limit) || $counter &lt;= $limit) {
            selectArticle($class, $temp{$key});
            my $criterium = 1;
            $criterium = 0 if ($cover eq "no" &amp;&amp; articleIsCover($class));
            $criterium = 0 if ($published eq "yes" &amp;&amp; !articleIsPublished($class));
            if ($criterium) {
                $counter++;
                if ($raw eq "yes") {
                    push(@result, $key . "{" . $temp{$key});
		} else {
                    push(@result, $temp{$key});
		}
	    }
        }
    }
    return @result;
}

sub selectArticle {
    my ($class, $artid) = @_;
    die "No article ID given!$/" if (!defined $artid);

    $class-&gt;{articleid} = $artid;
    my $nodes = $class-&gt;{doc}-&gt;getElementsByTagName ("article");
    my $n = $nodes-&gt;getLength;

    for (my $i = 0; $i &lt; $n; $i++) {
        my $node = $nodes-&gt;item ($i);
        my $id = $node-&gt;getAttribute ("id");
        if ($id eq $artid) {
	    $class-&gt;{article} = $node;
	}
    }    
}

sub articleIsPublished {
    my ($class) = @_;

    my $result = 0;
    if (issueIsPublished($class, getArticleMonthID($class))) {
	$result = 1;
    }
    return $result;
}

sub articleIsCover {
    my ($class) = @_;

    my $result = 0;

    my $arttype = $class-&gt;{article}-&gt;getAttribute("type") || "article";
    if ($arttype eq "coverpage") {
	$result = 1;
    }
    return $result;
}

sub getArticleMonthID {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    foreach my $kid ($class-&gt;{article}-&gt;getElementsByTagName ("issue")) {
	$result = $kid-&gt;getAttribute("href");
    }
    return $result;
}

sub getArticleMonth {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    foreach my $kid ($class-&gt;{article}-&gt;getElementsByTagName ("issue")) {
	my $id = $kid-&gt;getAttribute("href");
        $result = getMonthName($class, $id, $olang);
    }
    return $result;
}

sub getArticleTitle {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $title = "";
    return $title if (!defined $class-&gt;{article});

    foreach my $kid ($class-&gt;{article}-&gt;getElementsByTagName ("title")) {
        if ($kid-&gt;getAttribute("xml:lang") eq $olang) {
            my @titlenode = $kid-&gt;getChildNodes();
            if (scalar @titlenode &gt; 0) {
      	        $title = $titlenode[0]-&gt;toString();
	    }
	} elsif (($kid-&gt;getAttribute("xml:lang") eq "en") &amp;&amp;
                 ($title eq "")) {
            $title = (($kid-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
        } elsif (($kid-&gt;getAttribute("xml:lang") eq getArticleOriginalLanguage($class)) &amp;&amp;
                 ($title eq "")) {
            $title = (($kid-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
        }
    }
    $title = "" if (!defined $title);
    return $title;
}

sub getIssueRL {
    my ($class, $id, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    die "No issue is selected!$/" if (!defined $id);

    my $result = $id;

    my $issues = $class-&gt;{doc}-&gt;getElementsByTagName("issues");
    return $result if (!defined $issues-&gt;item(0));

    foreach my $kid ($issues-&gt;item(0)-&gt;getElementsByTagName ("issue")) {
	if ($kid-&gt;getAttribute("id") eq $id) {
            my @titles = $kid-&gt;getElementsByTagName("file");
            foreach my $title (@titles) {
                if ($title-&gt;getAttribute("xml:lang") eq $olang) {
                    $result = (($title-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
		}
 	    }
        };
    }
    return $result;
}

sub getArticleRL {
    my ($class, $olang, %args) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);
    my $meta = $args{meta} || "target";

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    foreach my $kid ($class-&gt;{article}-&gt;getElementsByTagName ("file")) {
        my $type = $kid-&gt;getAttribute("type") || "target";
        if ($kid-&gt;getAttribute("xml:lang") eq $olang &amp;&amp; ($type eq $meta)) {
	    if (($kid-&gt;getChildNodes())-&gt;item(0)) {
		$result = (($kid-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
	    }
	}
    }
    return $result;
}


sub getArticleThemeID {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    die "No article is selected!$/" if (!defined $class-&gt;{article});

    my $result = "";
    foreach my $kid ($class-&gt;{article}-&gt;getElementsByTagName ("theme")) {
	$result = $kid-&gt;getAttribute("href");
    }
    return $result;
}

sub getArticleTheme {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    if (my $theme = getArticleThemeID($class)) {
	$result = getTheme($class, $theme, $olang);
    }
    return $result;
}

sub getArticleOriginalLanguage {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    $result = $class-&gt;{article}-&gt;getAttribute("xml:lang") || "";
    return $result;
}

sub getArticleTranslationDate {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    my $result = "";

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    if (getArticleOriginalLanguage($class) eq $to) {
        $result = "1900-01-01";
    } else {
        foreach my $transnode (@transnodes) {
            if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
                ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
                my @nodes = $transnode-&gt;getElementsByTagName("finished");
                if (scalar @nodes &gt; 0) {
                    $result = "1900-01-01";
                    my @datenode = $nodes[0]-&gt;getChildNodes();
                    if (scalar @datenode &gt; 0) {
                        $result = ($datenode[0])-&gt;toString();
		    } else {
                        # date is unknown
		    }
                }
            }
	}
    }

    return $result;
}

sub getArticleTranslationPerson {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    if (getArticleOriginalLanguage($class) eq $to) {
        $result = getArticleAuthor($class);
    } else {
        foreach my $transnode (@transnodes) {
            if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
                ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
                $result = getPersonName($class, ($transnode-&gt;getElementsByTagName("person"))-&gt;item(0)-&gt;getAttribute("href"));
	    }
	}
    }
    return $result;
}   

sub getArticleTranslationPersonID {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    if (getArticleOriginalLanguage($class) eq $to) {
        $result = getArticleAuthor($class);
    } else {
        foreach my $transnode (@transnodes) {
            if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
                ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
                $result = ($transnode-&gt;getElementsByTagName("person"))-&gt;item(0)-&gt;getAttribute("href");
	    }
	}
    }
    return $result;
}   

sub getArticleTranslationPersonEmail {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});

    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    return $result if (!@transnodes);

    if (getArticleOriginalLanguage($class) eq $to) {
        $result = getArticleAuthorEmail($class);
    } else {
        foreach my $transnode (@transnodes) {
            if (defined $transnode) {
              if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
                  ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
                  $result = getPersonEmail($class, ($transnode-&gt;getElementsByTagName("person"))-&gt;item(0)-&gt;getAttribute("href"));
	      }
	    }
	}
    }
    return $result;
}

sub getArticleTranslationReservationDate {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    return "" if (!defined $class-&gt;{article});
    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));

    my $result = "";
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    foreach my $transnode (@transnodes) {
        if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
            ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
            my $nodes = $transnode-&gt;getElementsByTagName("reserved");
            if ($nodes &amp;&amp; $nodes-&gt;getLength &gt; 0) {
                if ($nodes-&gt;item(0)-&gt;getChildNodes()-&gt;item(0)) {
		    $result = $nodes-&gt;item(0)-&gt;getChildNodes()-&gt;item(0)-&gt;toString();
		}
            }
	}
    }
    return $result;
}   

sub getArticleTranslationProofreadDate {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    foreach my $transnode (@transnodes) {
        if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
            ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
            my $nodes = $transnode-&gt;getElementsByTagName("proofread");
            if ($nodes-&gt;getLength &gt; 0) {
                $result = $nodes-&gt;item(0)-&gt;getChildNodes()-&gt;item(0)-&gt;toString();
            }
	}
    }
    return $result;
}   

sub getArticleTranslationProofreadPerson {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    foreach my $transnode (@transnodes) {
        if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
            ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
            my @proofreadnodes = $transnode-&gt;getElementsByTagName("proofread");
            $result = getPersonName($class, (($proofreadnodes[0])-&gt;getElementsByTagName("person")-&gt;item(0))-&gt;getAttribute("href"));
	}
    }
    return $result;
}   

sub getArticleTranslationProofreadPersonID {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    foreach my $transnode (@transnodes) {
        if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
            ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
            my @proofreadnodes = $transnode-&gt;getElementsByTagName("proofread");
            $result = (($proofreadnodes[0])-&gt;getElementsByTagName("person")-&gt;item(0))-&gt;getAttribute("href");
	}
    }
    return $result;
}   

sub getArticleTranslationProofreadPersonEmail {
    my ($class, %args) = @_;
    my $from = ($args{"from"} || "*");
    my $to = ($args{"to"} || "*");

    die "No translation given!$/" if (($from eq "*") &amp;&amp; ($to eq "*"));
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});
    
    my @transnodes = $class-&gt;{article}-&gt;getElementsByTagName("translation");
    foreach my $transnode (@transnodes) {
        if (($from eq "*" || $transnode-&gt;getAttribute("from") eq $from) &amp;&amp;
            ($to eq "*" || $transnode-&gt;getAttribute("to") eq $to)) {
            my @proofreadnodes = $transnode-&gt;getElementsByTagName("proofread");
            $result = getPersonEmail($class, (($proofreadnodes[0])-&gt;getElementsByTagName("person")-&gt;item(0))-&gt;getAttribute("href"));
	}
    }
    return $result;
}   

sub getArticleAuthor {
    my ($class) = @_;

    my $result = "";
    return $result if (!defined $class-&gt;{article});

    $result = getPersonName($class, getArticleAuthorID($class));
    return $result;
}

sub getArticleAuthorID {
    my ($class) = @_;
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});

    my $node = $class-&gt;{article}-&gt;getElementsByTagName("person")-&gt;item(0);
    $result = $node-&gt;getAttribute("href") if (defined $node);
    return $result;
}

sub getArticleAbstract {
    my ($class) = @_;
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});

    my $nodes = $class-&gt;{article}-&gt;getElementsByTagName("abstract");
    if ($nodes-&gt;getLength &gt; 0) {
        $result = ($nodes-&gt;item(0)-&gt;getChildNodes())-&gt;item(0)-&gt;toString();
        $result =~ s/(\n|\r)//g;
        $result =~ s/\s\s/ / while ($result =~ /\s\s/);
        $result =~ s/^\s//g while ($result =~ /^\s/);
    }
    return $result;
}

sub getArticleAuthorEmail {
    my ($class) = @_;
    
    my $result = "";
    return $result if (!defined $class-&gt;{article});

    $result = getPersonEmail($class, getArticleAuthorID($class));
    return $result;
}

sub getTheme {
    my ($class, $themeid, $olang) = @_;
    die "No theme id is given!$/" if (!defined $themeid);
    die "No language given!$/" if (!defined $olang);

    my $result = "";
    my $themes = $class-&gt;{doc}-&gt;getElementsByTagName("themes");
    foreach my $kid ($themes-&gt;item(0)-&gt;getElementsByTagName ("theme")) {
	if ($kid-&gt;getAttribute("id") eq $themeid) {
            my @titles = $kid-&gt;getElementsByTagName("title");
            foreach my $title (@titles) {
                if ($title-&gt;getAttribute("xml:lang") eq $olang) {
                    $result = (($title-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
		}
 	    }
        };
    }
    return $result;
}

sub getMonthName {
    my ($class, $id, $olang) = @_;
    die "No id is given!$/" if (!defined $id);
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "";
    my $themes = $class-&gt;{doc}-&gt;getElementsByTagName("issues");
    if ($themes-&gt;item(0)) {
	foreach my $kid ($themes-&gt;item(0)-&gt;getElementsByTagName ("issue")) {
	    if ($kid-&gt;getAttribute("id") eq $id) {
		my @titles = $kid-&gt;getElementsByTagName("title");
		foreach my $title (@titles) {
		    if ($title-&gt;getAttribute("xml:lang") eq $olang) {
			$result = (($title-&gt;getChildNodes())-&gt;item(0))-&gt;toString();
		    }
		}
 	    }
        };
    }
    return $result;
}

sub issueIsPublished {
    my ($class, $id) = @_;
    die "No issue id is given!$/" if (!defined $id);

    my $result = 0;
    my $themes = $class-&gt;{doc}-&gt;getElementsByTagName("issues");
    foreach my $kid ($themes-&gt;item(0)-&gt;getElementsByTagName ("issue")) {
	if ($kid-&gt;getAttribute("id") eq $id) {
            my @pub = $kid-&gt;getElementsByTagName("published");
            if (defined $pub[0]) {
                $result = 1;
            }
        };
    }
    return $result;
}

sub getPersonEmail {
    my ($class, $id) = @_;
    die "No person id is given!$/" if (!defined $id);

    my $result = "";
    my $persons = $class-&gt;{doc}-&gt;getElementsByTagName("persons");
    if (defined $persons-&gt;item(0)) {
        foreach my $kid ($persons-&gt;item(0)-&gt;getElementsByTagName ("person")) {
	    if ($kid-&gt;getAttribute("id") eq $id) {
                my $titles = $kid-&gt;getElementsByTagName("email");
		if ($titles-&gt;item(0)) {
		    $result = (($titles-&gt;item(0))-&gt;getChildNodes())-&gt;item(0)-&gt;toString();
		}
	    };
        };
    }
    return $result;
}

sub getPersonName {
    my ($class, $id) = @_;
    die "No person id is given!$/" if (!defined $id);

    my $result = "";
    my $persons = $class-&gt;{doc}-&gt;getElementsByTagName("persons");
    if (defined $persons-&gt;item(0)) {
        foreach my $kid ($persons-&gt;item(0)-&gt;getElementsByTagName ("person")) {
	    if ($kid-&gt;getAttribute("id") eq $id) {
                my $titles = $kid-&gt;getElementsByTagName("name");
		if ($titles-&gt;item(0)) {
		    $result = (($titles-&gt;item(0))-&gt;getChildNodes())-&gt;item(0)-&gt;toString();
		}
            };
	};
    }
    return $result;
}

sub getPersonNickname {
    my ($class, $id) = @_;
    die "No person id is given!$/" if (!defined $id);

    my $result = "";
    my $persons = $class-&gt;{doc}-&gt;getElementsByTagName("persons");
    foreach my $kid ($persons-&gt;item(0)-&gt;getElementsByTagName ("person")) {
	if ($kid-&gt;getAttribute("id") eq $id) {
            my @nicks = $kid-&gt;getElementsByTagName("nickname");
            my $node = $nicks[0];
            if (defined $node) {
                $result = $node-&gt;toString;
	    };
        };
    };
    return $result;
}

sub getPersonDescription {
    my ($class, $id) = @_;
    die "No person id is given!$/" if (!defined $id);

    my $result = "";
    my $persons = $class-&gt;{doc}-&gt;getElementsByTagName("persons");
    foreach my $kid ($persons-&gt;item(0)-&gt;getElementsByTagName ("person")) {
	if ($kid-&gt;getAttribute("id") eq $id) {
            my @nicks = $kid-&gt;getElementsByTagName("desc");
            my $node = $nicks[0];
            if (defined $node) {
                $result = $node-&gt;toString;
	    };
        };
    };
    return $result;
}

sub getPersonStats {
    my ($class, $id, %args) = @_;
    my $to = ($args{"to"} || $class-&gt;{lang});

    die "No person id is given!$/" if (!defined $id);

    my %result = ();
    my $translated = 0;
    my $proofread = 0;
    my $written = 0;
    foreach my $artid (getArticleIDs($class, coverpages =&gt; "yes")) {
        selectArticle($class, $artid);
        $written++ if (getArticleAuthorID($class) eq $id);
        $translated++ 
            if (getArticleTranslationDate($class, to =&gt; $to) &amp;&amp;
            getArticleTranslationPersonID($class, to =&gt; $to) eq $id);
        $proofread++ 
            if (getArticleTranslationProofreadDate($class, to =&gt; $to) &amp;&amp;
            getArticleTranslationProofreadPersonID($class, to =&gt; $to) eq $id);
    };
    $result{written} = $written;
    $result{translated} = $translated;
    $result{proofread} = $proofread;
    return %result;
}

sub getLanguageDir {
    my ($class, $olang) = @_;
    $olang = $class-&gt;{lang} if (!defined $olang);

    my $result = "English";
    if ($olang eq "nl") {
        $result = "Nederlands";
    } elsif ($olang eq "fr") {
        $result = "French";
    } elsif ($olang eq "de") {
        $result = "Deutsch";
    } elsif ($olang eq "es") {
        $result = "Castellano";
    }
    return $result;
}    

1;
</pre></body></html>