1414
1515require_once 'inc/session_utility.php ' ;
1616
17- function do_diplay_impr_text_header_data () {
17+ /**
18+ * Return the useful data for the header part of a printed text.
19+ *
20+ * @param int $textid Text ID
21+ *
22+ * @return array{0: string, 1: string, 2: string} Text title,
23+ * text audio and source URI
24+ *
25+ * @global string $tbpref Database table prefix.
26+ */
27+ function do_diplay_impr_text_header_data ($ textid ) {
1828 global $ tbpref ;
1929
20- $ textid = (int ) getreq ('text ' );
21- $ sql
22- = 'SELECT TxLgID, TxTitle, TxAudioURI, TxSourceURI
30+ $ sql =
31+ 'SELECT TxLgID, TxTitle, TxAudioURI, TxSourceURI
2332 FROM ' . $ tbpref . 'texts
2433 WHERE TxID = ' . $ textid ;
2534 $ res = do_mysqli_query ($ sql );
@@ -37,51 +46,73 @@ function do_diplay_impr_text_header_data() {
3746 mysqli_free_result ($ res );
3847
3948 saveSetting ('currenttext ' , $ textid );
40- return array ($ title , $ textid , $ audio , $ sourceURI );
49+ return array ($ title , $ audio , $ sourceURI );
4150}
4251
52+ /**
53+ * Echo JavaScript area containing behaviors to show/hide
54+ * translations and annotations.
55+ *
56+ * @return void
57+ */
4358function do_diplay_impr_text_header_js () {
4459
4560?>
4661
4762<script type="text/javascript">
48- //<![CDATA[
63+ //<![CDATA[
64+
65+ /** Hide traslations. */
4966 function do_hide_t() {
5067 $('#showt').show();
5168 $('#hidet').hide();
5269 $('.anntermruby')
5370 .css('color','#E5E4E2').css('background-color', '#E5E4E2');
5471 }
72+
73+ /** Show translations. */
5574 function do_show_t() {
5675 $('#showt').hide();
5776 $('#hidet').show();
5877 $('.anntermruby')
5978 .css('color','inherit').css('background-color', '');
6079 }
80+
81+ /** Hide annotations. */
6182 function do_hide_a() {
6283 $('#show').show();
6384 $('#hide').hide();
6485 $('.anntransruby2')
6586 .css('color','#C8DCF0').css('background-color', '#C8DCF0');
6687 }
88+
89+ /** Show annotations. */
6790 function do_show_a() {
6891 $('#show').hide();
6992 $('#hide').show();
7093 $('.anntransruby2')
7194 .css('color','').css('background-color', '');
7295 }
73- //]]>
96+ //]]>
7497</script>
7598
7699<?php
77100
78101}
79102
103+ /**
104+ * Make the header content to display a printed text.
105+ *
106+ * @param string $title Text title
107+ * @param int $textid Text ID
108+ * @param string $audio Audio URI
109+ * @param string $sourceURI Text source link
110+ *
111+ * @return void
112+ */
80113function do_diplay_impr_text_header_content ($ title , $ textid , $ audio , $ sourceURI ) {
81- //pagestart_nobody($title);
82- do_diplay_impr_text_header_js ();
83114 ?>
84- <h2 class="center" style="margin:5px;margin-top:-10px;">
115+ <h2 class="center" style="margin:5px;margin-top:-10px;">
85116 <img id="hidet" style="margin-bottom:-5px;" class="click" src="icn/light-bulb-T.png" title="Toggle Text Display (Now ON)" alt="Toggle Text Display (Now ON)" onclick="do_hide_t();" />
86117 <img id="showt" style="display:none; margin-bottom:-5px;" 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();" />
87118 <img id="hide" style="margin-bottom:-5px;" class="click" src="icn/light-bulb-A.png" title="Toggle Annotation Display (Now ON)" alt="Toggle Annotation Display (Now ON)" onclick="do_hide_a();" />
@@ -96,7 +127,8 @@ function do_diplay_impr_text_header_content($title, $textid, $audio, $sourceURI)
96127 }
97128 echo getPreviousAndNextTextLinks ($ textid , 'display_impr_text.php?text= ' , true , ' ' );
98129 ?>
99- <img class="click" src="icn/cross.png" title="Close Window" alt="Close Window" onclick="top.close();" /></span></h2>
130+ <img class="click" src="icn/cross.png" title="Close Window" alt="Close Window" onclick="top.close();" />
131+ </h2>
100132 <?php
101133 makeMediaPlayer ($ audio );
102134
@@ -105,10 +137,17 @@ function do_diplay_impr_text_header_content($title, $textid, $audio, $sourceURI)
105137 //pageend();
106138}
107139
108- function do_diplay_impr_text_header_main () {
109- list ($ title , $ textid , $ audio , $ sourceURI ) = do_diplay_impr_text_header_data ();
140+ /**
141+ * Main function to generate a complete header for a specific text.
142+ *
143+ * @param int $textid Text ID.
144+ *
145+ * @return void
146+ */
147+ function do_diplay_impr_text_header_main ($ textid ) {
148+ do_diplay_impr_text_header_js ();
149+ list ($ title , $ audio , $ sourceURI ) = do_diplay_impr_text_header_data ($ textid );
110150 do_diplay_impr_text_header_content ($ title , $ textid , $ audio , $ sourceURI );
111151}
112152
113- do_diplay_impr_text_header_main ();
114153?>
0 commit comments