44 * \file
55 * \brief Start Reading a text (frameset)
66 *
7- * Call: do_text.php?start =[textid]
7+ * Call: do_text.php?text =[textid]
88 * Create the main window when reading texts.
99 *
1010 * @package Lwt
1919require_once 'do_text_header.php ' ;
2020require_once 'do_text_text.php ' ;
2121
22+ /**
23+ * Get text ID (if possible).
24+ *
25+ * Text ID if first looked at int the 'text' parameter. If not found, then look at 'start'.
26+ *
27+ * @return int|null Text ID or null
28+ */
29+ function get_text_id () {
30+ if (isset ($ _REQUEST ['text ' ]) && is_integer ($ _REQUEST ['text ' ])) {
31+ return (int )$ _REQUEST ['text ' ];
32+ }
33+ if (isset ($ _REQUEST ['start ' ]) && is_integer ($ _REQUEST ['start ' ])) {
34+ return (int )$ _REQUEST ['start ' ];
35+ }
36+ return null ;
37+ }
38+
2239/**
2340 * Echo the page content for the mobile version of do_text.
2441 *
42+ * @param int $textid Text ID
43+ *
2544 * @return void
2645 */
27- function do_text_mobile_content () {
46+ function do_text_mobile_content ($ textid ) {
2847?>
2948<div id="frame-h">
3049 <iframe id="frame-h-2"
31- src="do_text_header.php?text=<?php echo $ _REQUEST [ ' start ' ] ; ?> "
50+ src="do_text_header.php?text=<?php echo $ textid ; ?> "
3251 scrolling="yes" name="h">
3352 </iframe>
3453</div>
@@ -37,7 +56,7 @@ function do_text_mobile_content() {
3756</div>
3857<div id="frame-l">
3958 <iframe id="frame-l-2"
40- src="do_text_text.php?text=<?php echo $ _REQUEST [ ' start ' ] ; ?> " scrolling="yes" name="l">
59+ src="do_text_text.php?text=<?php echo $ textid ; ?> " scrolling="yes" name="l">
4160 </iframe>
4261</div>
4362<div id="frame-ru">
@@ -50,19 +69,20 @@ function do_text_mobile_content() {
5069/**
5170 * Echo the page content for the desktop version of do_text.
5271 *
53- * @param string|null Audio URI
72+ * @param int $textid Text ID
73+ * @param string|null $audio Audio URI
5474 *
5575 * @return void
5676 */
57- function do_text_desktop_content ($ audio ) {
77+ function do_text_desktop_content ($ textid , $ audio ) {
5878?>
59- <div style="width: 95%; height: 100%;" onclick="setTimeout(hideRightFrames, 1000);" >
79+ <div style="width: 95%; height: 100%;">
6080 <div id="frame-h">
61- <?php do_text_header_content ($ _REQUEST [ ' start ' ] , true ); ?>
81+ <?php do_text_header_content ($ textid , true ); ?>
6282 </div>
6383 <hr />
6484 <div id="frame-l">
65- <?php do_text_text_content ($ _REQUEST [ ' start ' ] , true ); ?>
85+ <?php do_text_text_content ($ textid , true ); ?>
6686 </div>
6787</div>
6888<div id="frames-r" style="position: fixed; top: 0; right: -100%; width: 100%; height: 100%;"
@@ -84,13 +104,14 @@ function do_text_desktop_content($audio) {
84104/**
85105 * Echo the text page.
86106 *
87- * @param bool Set to true if you want the mobile version of the page.
107+ * @param int $textit Text ID
108+ * @param bool $mobile Set to true if you want the mobile version of the page.
88109 *
89110 * @return void
90111 *
91112 * @global string $tbpref Database table prefix.
92113 */
93- function do_text_page ($ mobile )
114+ function do_text_page ($ textid , $ mobile )
94115{
95116 global $ tbpref ;
96117
@@ -106,16 +127,16 @@ function do_text_page($mobile)
106127 if ($ mobile && false ) {
107128 do_frameset_mobile_css ();
108129 do_frameset_mobile_js ($ audio );
109- do_text_mobile_content ();
130+ do_text_mobile_content ($ textid );
110131 } else {
111132 // Not mobile
112- do_text_desktop_content ($ audio );
133+ do_text_desktop_content ($ textid , $ audio );
113134 }
114135 pageend ();
115136}
116137
117- if (isset ( $ _REQUEST [ ' start ' ]) ) {
118- do_text_page (is_mobile ());
138+ if (get_text_id () !== null ) {
139+ do_text_page (get_text_id (), is_mobile ());
119140} else {
120141 // Document not ready
121142 header ("Location: edit_texts.php " );
0 commit comments