#!/usr/bin/perl -w # -- # xml2docbook.pl - config xml to docbook # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/ # -- # $Id: xml2docbook.pl,v 1.13 2007/02/13 15:04:06 tr Exp $ # -- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -- # use ../ as lib location use File::Basename; use FindBin qw($RealBin); use lib dirname($RealBin)."/../"; use lib dirname($RealBin)."/../Kernel/cpan-lib"; use strict; use Getopt::Std; use vars qw($VERSION); $VERSION = '$Revision: 1.13 $'; $VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; use Kernel::Config; use Kernel::System::Log; use Kernel::System::Main; use Kernel::System::Time; use Kernel::System::DB; use Kernel::System::Config; # create common objects my %CommonObject = (); $CommonObject{ConfigObject} = Kernel::Config->new(); $CommonObject{LogObject} = Kernel::System::Log->new( LogPrefix => 'OTRS-xml2docbook', %CommonObject, ); $CommonObject{MainObject} = Kernel::System::Main->new(%CommonObject); $CommonObject{TimeObject} = Kernel::System::Time->new(%CommonObject); $CommonObject{DBObject} = Kernel::System::DB->new(%CommonObject); $CommonObject{SysConfigObject} = Kernel::System::Config->new(%CommonObject); # list Groups #my %List = $CommonObject{SysConfigObject}->ConfigGroupList(); my @Groups = (qw(Framework Ticket)); my $UserLang = ''; # get options my %Opts = (); getopt('l', \%Opts); if ($Opts{'l'}) { $UserLang = $Opts{'l'}; } else { die "Need -l \n"; } # start xml output print 'Get('DefaultCharset') . '"?> '; print "\nConfig Referenzliste\n"; foreach my $Group (@Groups) { my %SubList = $CommonObject{SysConfigObject}->ConfigSubGroupList(Name => $Group); print "$Group \n"; foreach my $SubGroup (sort keys %SubList) { print "$SubGroup \n"; my @List = $CommonObject{SysConfigObject}->ConfigSubGroupConfigItemList(Group => $Group, SubGroup => $SubGroup); foreach my $Name (@List) { my %Item = $CommonObject{SysConfigObject}->ConfigItemGet(Name => $Name); my $Link = $Name; $Link =~ s/###/_/g; $Link =~ s/\///g; print "$Name \n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " Description\n"; print " Value\n"; print " \n"; print " \n"; print " \n"; #Description my %HashLang; foreach my $Index (1...$#{$Item{Description}}) { $HashLang{$Item{Description}[$Index]{Lang}} = $Item{Description}[$Index]{Content}; } my $Description; # Description in User Language if (defined $HashLang{$UserLang}) { $Description = $HashLang{$UserLang}; } # Description in Default Language else { $Description = $HashLang{'en'}; } $Description =~ s/&/&/g; $Description =~ s//>/g; print "\n"; print " Description:\n"; print " $Description\n"; print "\n"; print "\n"; print " Group:\n"; print " $Group\n"; print "\n"; foreach my $Area (qw(SubGroup)) { foreach (1..10) { if ($Item{$Area}->[$_]) { print "\n"; print " $Area:\n"; print " $Item{$Area}->[$_]->{Content}\n"; print "\n"; } } } my %ConfigItemDefault = $CommonObject{SysConfigObject}->ConfigItemGet( Name => $Name, Default => 1, ); print "\n"; print " Valid:\n"; print " ".(defined $ConfigItemDefault{Valid} ? $ConfigItemDefault{Valid} : 1)."\n"; print "\n"; print "\n"; print " Required:\n"; print " ".(defined $ConfigItemDefault{Required} ? $ConfigItemDefault{Required} : 0)."\n"; print "\n"; my $Key = $Name; $Key =~ s/\\/\\\\/g; $Key =~ s/'/\'/g; $Key =~ s/###/'}->{'/g; my $Config = " \$Self->{'$Key'} = ".$CommonObject{SysConfigObject}->_XML2Perl(Data => \%ConfigItemDefault); $Config =~ s/&/&/g; $Config =~ s//>/g; print "\n"; print " Config-Setting:\n"; print " \n"; print $Config; print "\n"; print " \n"; print "\n"; print "\n"; print "\n"; print "\n"; print " \n"; } print " \n"; } print " \n"; } print " \n"; exit;