aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Common.pm
diff options
context:
space:
mode:
authordakkar <dakkar@luxion>2009-01-08 16:34:23 +0000
committerdakkar <dakkar@luxion>2009-01-08 16:34:23 +0000
commit74927a08f548ed3ce6bc330ddce605abb9a02a07 (patch)
tree1b4e82fdaa6cc8f43a51e0bd22649fc00bce52e7 /lib/WebCoso/Common.pm
parente pure i feed multilnigua (diff)
downloadWebCoso-74927a08f548ed3ce6bc330ddce605abb9a02a07.tar.gz
WebCoso-74927a08f548ed3ce6bc330ddce605abb9a02a07.tar.bz2
WebCoso-74927a08f548ed3ce6bc330ddce605abb9a02a07.zip
aggirato il problema dei titoli che in alcune lingue non esistono
git-svn-id: svn://luxion/repos/WebCoso/trunk@407 fcb26f47-9200-0410-b104-b98ab5b095f3
Diffstat (limited to 'lib/WebCoso/Common.pm')
-rw-r--r--lib/WebCoso/Common.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/WebCoso/Common.pm b/lib/WebCoso/Common.pm
index 6c9a433..f01e739 100644
--- a/lib/WebCoso/Common.pm
+++ b/lib/WebCoso/Common.pm
@@ -8,6 +8,7 @@ use DateTime;
use DateTime::Format::DateParse;
use Log::Log4perl ':easy';
use List::MoreUtils 'uniq';
+use List::Util 'first';
our $SRCPATH='src';
our $DSTPATH='dst';
@@ -91,10 +92,23 @@ sub isLang {
sub getTitleFor {
my ($fc,$lang,$path,$name)=@_;
DEBUG("getTitleFor($lang,$path,$name)");
- my $doc_name=srcXMLFor($lang,$path,$name);
- DEBUG("getTitleFor -> $doc_name");
+ my ($doc_name,$doc);
+
+ if (ref($lang)) { # assume it's an array
+ for my $l (@$lang) {
+ $doc_name=srcXMLFor($l,$path,$name);
+ DEBUG("getTitleFor -> try $doc_name");
+ $doc=$fc->get($doc_name);
+ last if $doc;
+ }
+ }
+ else {
+ $doc_name=srcXMLFor($lang,$path,$name);
+ DEBUG("getTitleFor -> $doc_name");
+
+ $doc=$fc->get($doc_name);
+ }
- my $doc=$fc->get($doc_name);
unless ($doc) {
LOGWARN("No document for <$doc_name>, returning <$name>");
return "$name"; # force it to a string, since it might be an XML Node