forked from Gnucash/gnucash-htdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewdoc.phtml
135 lines (119 loc) · 4 KB
/
viewdoc.phtml
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
<?php
# Determine which documentation to show based on 3 parameters:
# - language (lang)
# - help or guide (doc)
# - doc version (rev)
include("emulate_globals_on.php");
include("lang.php");
$title = T_("View document");
include("externals/header.phtml");
include("externals/menu.phtml");
# Some base parameters used later on
$basepath = "https://www.gnucash.org/docs";
$helpdoc = "gnucash-help/help.html";
$tcdoc = "gnucash-guide/index.html";
$current_stable = "2.6";
# Show current stable helpdoc, in overall set language by default
$showdoc = $tcdoc;
$req_doc_ok = true;
$showrev = $current_stable;
$req_rev_ok = true;
if (isset ($_GET["lang"])) {
$showlang = $_GET["lang"];
} else {
# Fallback: Requested language is set in $locale by included lang.php
if ($locale == "en_US") {
$showlang = "C";
} else {
$showlang = $locale;
}
}
$req_lang_ok = true;
# Parse requested document
if (isset ($_GET["doc"])) {
switch ($_GET["doc"]) {
case "help":
$showdoc = $helpdoc;
break;
case "guide":
$showdoc = $tcdoc;
break;
default: /* unknown document requested, will present help by default */
$req_doc_ok = false;
break;
}
}
# Parse requested version
if (isset ($_GET["rev"])) {
switch ($_GET["rev"]) {
case "1.8":
$showrev = "1.8";
break;
case "2.0":
$showrev = "2.0";
break;
case "2.2":
$showrev = "2.2";
break;
case "2.4":
$showrev = "2.4";
break;
case "2.6":
$showrev = "2.6";
break;
case "current":
$showrev = $current_stable;
break;
case "trunk":
$showrev = "trunk";
break;
case "nightly":
$showrev = "trunk";
break;
default: /* unknown version requested, will current stable by default */
$req_rev_ok = false;
break;
}
}
# Now check if the requested combination of doc, revision and language actually exists
# If not, try the default C locale instead.
# First evaluate the nightly builds, they are located on a different server
# To avoid network traffic, the available languages are hard-coded here and should be
# updated if list of languages in which the documentation is available changes
if ($showrev == "trunk") {
$basepath = "https://lists.gnucash.org/docs";
$trunk_langs = array ( $helpdoc => array( "C", "de", "it", "pt"),
$tcdoc => array( "C", "de", "it", "ja", "pt"));
if (!in_array ($showlang, $trunk_langs[$showdoc])) {
$showlang = "C";
$req_lang_ok = false;
}
$showurl=$basepath."/".$showlang."/".$showdoc;
} else {
# For the stable versions, we can simply check file availability because we're
# on the same server
$checkpath="docs/v".$showrev."/".$showlang."/".$showdoc;
if (!file_exists ($checkpath)) {
$showlang = "C";
$req_lang_ok = false;
}
$showurl=$basepath."/v".$showrev."/".$showlang."/".$showdoc;
}
?>
<div id="content">
<?php if (! $req_doc_ok ) { ?>
<p style="color: red;"><?= T_("The document requested is not available. The tutorial and concepts guide will be displayed instead.")?></p>
<?php } ?>
<?php if (! $req_rev_ok ) {
$reqrev=$_GET["rev"]; ?>
<p style="color: red;"><?php printf (T_("The document requested is not available for version %s. Version %s will be displayed instead."),
$reqrev, $showrev); ?></p>
<?php } ?>
<?php if (! $req_lang_ok ) { ?>
<p style="color: red;"><?= T_("The document requested is not available in the requested language. The English version will be displayed instead.")?></p>
<?php } ?>
<iframe src="<?php echo $showurl; ?>" style="border-width: 0px; width: 100%; min-width: 700px; height: 80em;">
<?php printf (T_("It seems your browser doesn't support iframes. To view the requested page in a separate window, please <a href=\"%s\" target=\"_new\">click here</a>."), $showurl); ?>
</iframe>
</div>
<?php include("externals/footer.phtml"); ?>