forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
/
display_impr_text_header.php
170 lines (151 loc) · 4.46 KB
/
display_impr_text_header.php
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
<?php
/**
* \file
* \brief Display an improved annotated text (top frame)
*
* Call: display_impr_text_header.php?text=[textid]
*
* PHP version 8.1
*
* @package Lwt
* @author LWT Project <[email protected]>
* @license Unlicense <http://unlicense.org/>
* @link https://hugofara.github.io/lwt/docs/php/files/display-impr-text-header.html
* @since 1.5.0
*/
require_once 'inc/session_utility.php';
/**
* Return the useful data for the header part of a printed text.
*
* @param int $textid Text ID
*
* @return array{0: string, 1: string, 2: string} Text title,
* text audio and source URI
*
* @global string $tbpref Database table prefix.
*/
function do_diplay_impr_text_header_data($textid)
{
global $tbpref;
$sql =
'SELECT TxLgID, TxTitle, TxAudioURI, TxSourceURI
FROM ' . $tbpref . 'texts
WHERE TxID = ' . $textid;
$res = do_mysqli_query($sql);
$record = mysqli_fetch_assoc($res);
if (isset($record['TxAudioURI'])) {
$audio = trim((string) $record['TxAudioURI']);
} else {
$audio = '';
}
$title = $record['TxTitle'];
$sourceURI = $record['TxSourceURI'];
mysqli_free_result($res);
saveSetting('currenttext', $textid);
return array($title, $audio, $sourceURI);
}
/**
* Echo JavaScript area containing behaviors to show/hide
* translations and annotations.
*
* @return void
*/
function do_diplay_impr_text_header_js()
{
?>
<script type="text/javascript">
//<![CDATA[
/** Hide traslations. */
function do_hide_t() {
$('#showt').show();
$('#hidet').hide();
$('.anntermruby')
.css('color','#E5E4E2').css('background-color', '#E5E4E2');
}
/** Show translations. */
function do_show_t() {
$('#showt').hide();
$('#hidet').show();
$('.anntermruby')
.css('color','inherit').css('background-color', '');
}
/** Hide annotations. */
function do_hide_a() {
$('#show').show();
$('#hide').hide();
$('.anntransruby2')
.css('color','#C8DCF0').css('background-color', '#C8DCF0');
}
/** Show annotations. */
function do_show_a() {
$('#show').hide();
$('#hide').show();
$('.anntransruby2')
.css('color','').css('background-color', '');
}
//]]>
</script>
<?php
}
/**
* Make the header content to display a printed text.
*
* @param string $title Text title
* @param int $textid Text ID
* @param string $audio Audio URI
* @param string $sourceURI Text source link
*
* @return void
*/
function do_diplay_impr_text_header_content($title, $textid, $audio, $sourceURI)
{
$text_links = getPreviousAndNextTextLinks(
$textid,
'display_impr_text.php?text=',
true,
' '
);
?>
<h1><?php echo tohtml($title); ?></h1>
<div class="flex-spaced">
<div>
<img id="hidet" class="click" src="icn/light-bulb-T.png"
title="Toggle Text Display (Now ON)" alt="Toggle Text Display (Now ON)" onclick="do_hide_t();" />
<img id="showt" style="display:none;" class="click" src="icn/light-bulb-off-T.png"
title="Toggle Text Display (Now OFF)" alt="Toggle Text Display (Now OFF)" onclick="do_show_t();" />
<img id="hide" class="click" src="icn/light-bulb-A.png"
title="Toggle Annotation Display (Now ON)" alt="Toggle Annotation Display (Now ON)" onclick="do_hide_a();" />
<img id="show" style="display:none;" class="click" src="icn/light-bulb-off-A.png"
title="Toggle Annotation Display (Now OFF)" alt="Toggle Annotation Display (Now OFF)" onclick="do_show_a();" />
</div>
<div>
<?php
if (isset($sourceURI)) {
echo ' <a href="' . $sourceURI . '" target="_blank">
<img src="'.get_file_path('icn/chain.png').'" title="Text Source" alt="Text Source" />
</a>';
}
echo $text_links;
?>
</div>
<div>
<img class="click" src="icn/cross.png" title="Close Window" alt="Close Window" onclick="top.close();" />
</div>
</div>
<?php
makeMediaPlayer($audio);
}
/**
* Main function to generate a complete header for a specific text.
*
* @param int $textid Text ID.
*
* @return void
*/
function do_diplay_impr_text_header_main($textid)
{
do_diplay_impr_text_header_js();
list($title, $audio, $sourceURI) = do_diplay_impr_text_header_data($textid);
do_diplay_impr_text_header_content($title, $textid, $audio, $sourceURI);
}
?>