| 1 | package AxKit::App::TABOO::Data::Language; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Carp; | ||
| 5 | use Encode; | ||
| 6 | |||
| 7 | use Data::Dumper; | ||
| 8 | use AxKit::App::TABOO::Data; | ||
| 9 | use vars qw/@ISA/; | ||
| 10 | @ISA = qw(AxKit::App::TABOO::Data); | ||
| 11 | |||
| 12 | use DBI; | ||
| 13 | use Exception::Class::DBI; | ||
| 14 | use MIME::Types; | ||
| 15 | |||
| 16 | |||
| 17 | our $VERSION = '0.3'; | ||
| 18 | |||
| 19 | |||
| 20 | =head1 NAME | ||
| 21 | |||
| 22 | AxKit::App::TABOO::Data::Language - Language Data objects for TABOO | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | use AxKit::App::TABOO::Data::Language; | ||
| 27 | $type = AxKit::App::TABOO::Data::Language->new(@dbconnectargs); | ||
| 28 | $type->load(limit => {code => 'no'}); | ||
| 29 | |||
| 30 | |||
| 31 | =head1 DESCRIPTION | ||
| 32 | |||
| 33 | This contains a simple class for ISO 639 language codes. | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | AxKit::App::TABOO::Data::Language->elementorder("code, localname"); | ||
| 38 | AxKit::App::TABOO::Data::Language->dbfrom("languages"); | ||
| 39 | |||
| 40 | =head1 METHODS | ||
| 41 | |||
| 42 | This class reimplements only one method in addition to the | ||
| 43 | constructor, the rest is inherited from L<AxKit::App::TABOO::Data>. | ||
| 44 | |||
| 45 | =over | ||
| 46 | |||
| 47 | =item C<new(@dbconnectargs)> | ||
| 48 | |||
| 49 | The constructor. Nothing special. | ||
| 50 | |||
| 51 | |||
| 52 | =item C<load(what =E<gt> fields, limit =E<gt> {code =E<gt> value, [...]})> | ||
| 53 | |||
| 54 | Nothing very different from other load methods. You would usually load | ||
| 55 | an object by specifying the C<mimetype> as in the above example. | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | sub load { | ||
| 60 | my ($self, %args) = @_; | ||
| 61 | my $data = $self->_load(%args); | ||
| 62 | if ($data) { | ||
| 63 | ${$self}{'ONFILE'} = 1; | ||
| 64 | } else { | ||
| 65 | return undef; | ||
| 66 | } | ||
| 67 | $self->populate($data); | ||
| 68 | return $self; | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | =back | ||
| 73 | |||
| 74 | =head1 STORED DATA | ||
| 75 | |||
| 76 | The data is stored in named fields, and for certain uses, it is good | ||
| 77 | to know them. If you want to subclass this class, you might want to | ||
| 78 | use the same names, see the documentation of | ||
| 79 | L<AxKit::APP::TABOO::Data> for more about this. These are the names of | ||
| 80 | the stored data of this class: | ||
| 81 | |||
| 82 | =over | ||
| 83 | |||
| 84 | =item * code | ||
| 85 | |||
| 86 | The ISO 639 two-letter code | ||
| 87 | |||
| 88 | =item * localname | ||
| 89 | |||
| 90 | An expanded name intended for human consumption. Must be in the code's | ||
| 91 | own langugage. | ||
| 92 | |||
| 93 | |||
| 94 | =back | ||
| 95 | |||
| 96 | =head1 XML representation | ||
| 97 | |||
| 98 | The C<write_xml()> method, implemented in the parent class, can be | ||
| 99 | used to create an XML representation of the data in the object. The | ||
| 100 | above names will be used as element names. The C<xmlelement()>, | ||
| 101 | C<xmlns()> and C<xmlprefix()> methods can be used to set the name of | ||
| 102 | the root element, the namespace URI and namespace prefix | ||
| 103 | respectively. Usually, it doesn't make sense to change the default | ||
| 104 | namespace, prefix, or root element that are | ||
| 105 | |||
| 106 | =over | ||
| 107 | |||
| 108 | =item * C<http://www.kjetil.kjernsmo.net/software/TABOO/NS/Language/Output> | ||
| 109 | |||
| 110 | =item * C<lang> | ||
| 111 | |||
| 112 | =item * C<language> | ||
| 113 | |||
| 114 | =back | ||
| 115 | |||
| 116 | |||
| 117 | =cut | ||
| 118 | |||
| 119 | sub new { | ||
| 120 | my $that = shift; | ||
| 121 | my $class = ref($that) || $that; | ||
| 122 | my $self = { | ||
| 123 | localname => undef, | ||
| 124 | code => undef, | ||
| 125 | DBCONNECTARGS => \@_, | ||
| 126 | XMLELEMENT => 'language', | ||
| 127 | XMLPREFIX => 'type', | ||
| 128 | XMLNS => 'http://www.kjetil.kjernsmo.net/software/TABOO/NS/Language/Output', | ||
| 129 | ONFILE => undef, | ||
| 130 | }; | ||
| 131 | bless($self, $class); | ||
| 132 | return $self; | ||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | =head1 FORMALITIES | ||
| 137 | |||
| 138 | See L<AxKit::App::TABOO>. | ||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | 1; | ||
| 143 | |||
| 144 |