1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
# --
# Copyright (C) 2001-2021 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::Console::Command::Dev::Tools::Config2Docbook;
use strict;
use warnings;
use utf8;
use parent qw(Kernel::System::Console::BaseCommand);
our @ObjectDependencies = (
'Kernel::Language',
'Kernel::System::DB',
'Kernel::System::SysConfig',
'Kernel::System::YAML',
);
sub Configure {
my ( $Self, %Param ) = @_;
$Self->Description('Generate a config options reference chapter (docbook) for the administration manual.');
$Self->AddOption(
Name => 'language',
Description => "Which language to use.",
Required => 1,
HasValue => 1,
ValueRegex => qr/.*/smx,
);
return;
}
sub Run {
my ( $Self, %Param ) = @_;
my $UserLanguage = $Self->GetOption('language');
$Kernel::OM->ObjectParamAdd(
'Kernel::Language' => {
UserLanguage => $UserLanguage,
},
);
my $LanguageObject = $Kernel::OM->Get('Kernel::Language');
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
return if !$DBObject->Prepare(
SQL => '
SELECT DISTINCT navigation
FROM sysconfig_default
ORDER by navigation',
);
my %NavigationGroups;
while ( my @Row = $DBObject->FetchrowArray() ) {
$NavigationGroups{ $Row[0] } = 1;
}
print <<'EOF';
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<!-- Note: this file is autogenerated by Dev::Tools::Config2Docbook -->
EOF
my $AppendixTitle = $LanguageObject->Translate('Configuration Options Reference');
print <<"EOF";
<appendix id=\"ConfigReference\">
<title>$AppendixTitle</title>
EOF
my $SysConfigObject = $Kernel::OM->Get('Kernel::System::SysConfig');
my $YAMLObject = $Kernel::OM->Get('Kernel::System::YAML');
for my $Navigation ( sort { $a cmp $b } keys %NavigationGroups ) {
my @SettingsList = $SysConfigObject->ConfigurationListGet(
Navigation => $Navigation,
);
my $EscapedNavigation = $Navigation;
$EscapedNavigation =~ s{::}{_}smxg;
my $VisibleNavigation = $Navigation;
$VisibleNavigation =~ s{::}{ → }smxg;
print <<"EOF";
<section id=\"ConfigReference_Section_$EscapedNavigation\">
<title>$VisibleNavigation</title>
<variablelist>
EOF
for my $Setting (@SettingsList) {
my $Link = $Setting->{Name};
$Link =~ s/###/_/g;
$Link =~ s/[ ]/_/g;
$Link =~ s/\///g;
print <<EOF;
<varlistentry id="ConfigReference_Setting_$Link">
<term>$Setting->{Name}</term>
<listitem>
EOF
# Description in User Language
my $Description = $LanguageObject->Translate( $Setting->{Description} );
$Description =~ s/&/&/g;
$Description =~ s/</</g;
$Description =~ s/>/>/g;
print <<"EOF";
<para>$Description</para>
EOF
my %DefaultSetting = $SysConfigObject->SettingGet(
Name => $Setting->{Name},
Default => 1,
);
my $IsReadOnly = $DefaultSetting{IsReadOnly} // 0;
my $IsValid = $DefaultSetting{IsValid} // 1;
my $IsRequired = $DefaultSetting{IsRequired} // 0;
my $IsInvisible = $DefaultSetting{IsInvisible} // 0;
my $IsUserModificationPossible = $DefaultSetting{UserModificationPossible} // 0;
my $IsUserModificationActive = $DefaultSetting{UserModificationActive} // 0;
my $EffectiveValueStrg = $YAMLObject->Dump(
Data => $DefaultSetting{EffectiveValue},
);
if ($IsReadOnly) {
my $ReadOnlyText = $LanguageObject->Translate('This setting can not be changed.');
print <<"EOF";
<para>$ReadOnlyText</para>
EOF
}
elsif ( !$IsValid ) {
my $InvalidText = $LanguageObject->Translate('This setting is not active by default.');
print <<"EOF";
<para>$InvalidText</para>\
EOF
}
elsif ($IsRequired) {
my $RequiredText = $LanguageObject->Translate('This setting can not be deactivated.');
print <<"EOF";
<para>$RequiredText</para>
EOF
}
elsif ($IsInvisible) {
my $InvisibleText = $LanguageObject->Translate('This setting is not visible.');
print <<"EOF";
<para>$InvisibleText</para>
EOF
}
elsif ($IsUserModificationPossible) {
my $UserModificationText
= $LanguageObject->Translate('This setting can be overridden in the user preferences.');
if ( !$IsUserModificationActive ) {
$UserModificationText = $LanguageObject->Translate(
'This setting can be overridden in the user preferences, but is not active by default.'
);
}
print <<"EOF";
<para>$UserModificationText</para>
EOF
}
my $DefaultValueText = $LanguageObject->Translate('Default value');
print <<"EOF";
<para>$DefaultValueText:
<programlisting><![CDATA[$EffectiveValueStrg]]></programlisting>
</para>
</listitem>
</varlistentry>
EOF
}
print <<"EOF";
</variablelist>
</section>
EOF
}
print <<"EOF";
</appendix>
EOF
return $Self->ExitCodeOk();
}
1;
|