forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
/
do_text.php
160 lines (149 loc) · 4.03 KB
/
do_text.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
<?php
/**
* \file
* \brief Start Reading a text (frameset)
*
* Call: do_text.php?text=[textid]
* Create the main window when reading texts.
*
* PHP version 8.1
*
* @category User_Interface
* @package Lwt
* @author LWT Project <[email protected]>
* @license Unlicense <http://unlicense.org/>
* @link https://hugofara.github.io/lwt/docs/php/files/do-text.html
* @since 1.0.3
*/
require_once 'inc/session_utility.php';
require_once 'inc/mobile_interactions.php';
require_once 'do_text_header.php';
require_once 'do_text_text.php';
/**
* Get text ID (if possible).
*
* Text ID if first looked at int the 'text' parameter. If not found, then look at 'start'.
*
* @return int|null Text ID or null
*/
function get_text_id()
{
if (isset($_REQUEST['text']) && is_numeric($_REQUEST['text'])) {
return (int)$_REQUEST['text'];
}
if (isset($_REQUEST['start']) && is_numeric($_REQUEST['start'])) {
return (int)$_REQUEST['start'];
}
return null;
}
/**
* Echo the page content for the mobile version of do_text.
*
* @param int $textid Text ID
* @param mixed $audio Audio URI, unnused, null by default
*
* @return void
*
* @since 2.2.1 It also calls do_frameset_mobile_css and do_frameset_mobile_js
* @since 2.6.0-fork Rewrote to match the desktop version (between 2.2.1 and 2.6.0)
*/
function do_text_mobile_content($textid, $audio = null)
{
?>
<div style="width: 95%; height: 100%;">
<div id="frame-h">
<?php do_text_header_content($textid, true); ?>
</div>
<hr />
<div id="frame-l">
<?php do_text_text_content($textid, true); ?>
</div>
</div>
<div id="frames-r"
style="position: fixed; top: 0; right: -100%; width: 100%; height: 100%;"
onclick="hideRightFrames();">
<!-- iFrames wrapper for events -->
<div style="margin-left: 50%; height: 99%;">
<iframe src="empty.html" scrolling="auto" name="ro"
style="height: 50%; width: 100%;">
Your browser doesn't support iFrames, update it!
</iframe>
<iframe src="empty.html" scrolling="auto" name="ru"
style="height: 50%; width: 100%;">
Your browser doesn't support iFrames, update it!
</iframe>
</div>
</div>
<?php
}
/**
* Echo the page content for the desktop version of do_text.
*
* @param int $textid Text ID
* @param mixed $audio Audio URI, unnused, null by default
*
* @return void
*/
function do_text_desktop_content($textid, $audio = null)
{
$frame_l_width = (int)getSettingWithDefault('set-text-l-framewidth-percent');
?>
<div style="width: <?php echo $frame_l_width; ?>%;" id="frames-l">
<div id="frame-h">
<?php do_text_header_content($textid, true); ?>
</div>
<hr />
<div id="frame-l">
<?php do_text_text_content($textid, true); ?>
</div>
</div>
<div id="frames-r"
style="position: fixed; top: 2%; right: 0; height: 95%;
width: <?php echo 97 - $frame_l_width; ?>%;">
<!-- iFrames wrapper for events -->
<iframe src="empty.html" scrolling="auto" name="ro"
style="height: 50%; width: 100%;">
Your browser doesn't support iFrames, update it!
</iframe>
<iframe src="empty.html" scrolling="auto" name="ru"
style="height: 50%; width: 100%;">
Your browser doesn't support iFrames, update it!
</iframe>
</div>
<?php
}
/**
* Echo the text page.
*
* @param int $textit Text ID
* @param bool $mobile Set to true if you want the mobile version of the page.
*
* @since 2.2.1 The $mobile parameter is no longer required.
* @since 2.7.0 Adds a CSS rule to auto-enlarge the body.
*
* @return void
*/
function do_text_page($textid)
{
pagestart_nobody(
'Read',
"body {
margin: 20px;
max-width: 100%;
}"
);
if (is_mobile()) {
do_text_mobile_content($textid);
} else {
do_text_desktop_content($textid);
}
pageend();
}
if (get_text_id() !== null) {
do_text_page(get_text_id());
} else {
// Document not ready
header("Location: edit_texts.php");
exit();
}
?>