1 |
<?php |
2 |
|
3 |
/* |
4 |
----------------------------------- |
5 |
*** progressive media *** |
6 |
|
7 |
pm-dcsl.php.inc |
8 |
Progressive Media: |
9 |
Dynamic client support library. |
10 |
|
11 |
----------------------------------- |
12 |
|
13 |
$Id: pm-dcsl.php.inc,v 1.4 2000/12/11 20:56:50 amo Exp $ |
14 |
|
15 |
$Log: pm-dcsl.php.inc,v $ |
16 |
Revision 1.4 2000/12/11 20:56:50 amo |
17 |
+ cleaned up and modified browser detection (more granular and detailed) |
18 |
+ added helper-function 'dcsl_BrowserValues_Dump' |
19 |
|
20 |
Revision 1.3 2000/10/29 15:53:48 amo |
21 |
+ JavaScript-include-Direktiven jetzt mittels Funktion 'php_js_writeHTML_IncludeLibraries' |
22 |
diese wird aus der Frameset-Seite ('index_f.php') aufgerufen |
23 |
|
24 |
Revision 1.2 2000/10/27 12:09:22 amo |
25 |
+ neue Browser-Variable: '$s4y_cfg['browser']['dynamic']' |
26 |
|
27 |
Revision 1.1 2000/10/27 10:36:13 amo |
28 |
+ neu |
29 |
|
30 |
|
31 |
----------------------------------- |
32 |
*/ |
33 |
|
34 |
DEFINE ('MODULE_DCSL', 1); |
35 |
|
36 |
// ================================================ |
37 |
/* |
38 |
for browser-detection and feature/capability negotiation |
39 |
*/ |
40 |
// ================================================ |
41 |
|
42 |
function s4ycfg_setbrowservalues() { |
43 |
|
44 |
global $s4y_cfg, $HTTP_USER_AGENT; |
45 |
|
46 |
// ----------------------- |
47 |
// zuerst alle Features 'ausschalten' bzw. default-Werte setzen |
48 |
|
49 |
$s4y_cfg['browser']['agentstring'] = $HTTP_USER_AGENT; |
50 |
|
51 |
$s4y_cfg['browser']['detected_key'] = ''; |
52 |
$s4y_cfg['browser']['detected_name'] = 'Not detected.'; |
53 |
$s4y_cfg['browser']['detected_version'] = 'Not detected.'; |
54 |
|
55 |
$s4y_cfg['browser']['capability_dhtml'] = false; |
56 |
$s4y_cfg['browser']['capability_frames'] = false; |
57 |
$s4y_cfg['browser']['capability_tables'] = false; |
58 |
$s4y_cfg['browser']['capability_swf'] = false; |
59 |
$s4y_cfg['browser']['outputType'] = 'html'; |
60 |
$s4y_cfg['browser']['mime_type'] = 'text/html'; |
61 |
|
62 |
$s4y_cfg['browser']['is_msie'] = false; |
63 |
$s4y_cfg['browser']['is_netscape'] = false; |
64 |
|
65 |
|
66 |
// lokale (u.a. häufig verwendete) Variablen setzen |
67 |
$ua = $s4y_cfg['browser']['agentstring']; |
68 |
|
69 |
$slashpos = 0; |
70 |
$spacepos = 0; |
71 |
|
72 |
// ----------------------- |
73 |
// browservalues allgemein bestimmen |
74 |
|
75 |
// ist eine Versionsnummer im UserAgent-String enthalten? |
76 |
if ($slashpos = strpos($ua, '/')) { |
77 |
$s4y_cfg['browser']['detected_name'] = $s4y_cfg['browser']['detected_key'] = |
78 |
substr($ua, 0, $slashpos); |
79 |
$s4y_cfg['browser']['detected_version'] = |
80 |
substr($ua, $slashpos + 1, strpos($ua, " ", $slashpos) - $slashpos - 1); |
81 |
} |
82 |
|
83 |
// ----------------------- |
84 |
// browservalues spezifisch bestimmen: |
85 |
|
86 |
// html - Netscape |
87 |
if (strstr ($ua, 'ozilla')) { |
88 |
|
89 |
$slashpos = strpos($ua, "/"); |
90 |
$priv_version_ns = substr($ua, $slashpos + 1, strpos($ua, " ", $slashpos) - $slashpos - 1); |
91 |
|
92 |
$s4y_cfg['browser']['detected_key'] = 'NS'; |
93 |
$s4y_cfg['browser']['detected_name'] = 'Netscape'; |
94 |
$s4y_cfg['browser']['is_netscape'] = true; |
95 |
$s4y_cfg['browser']['is_msie'] = false; |
96 |
$s4y_cfg['browser']['detected_version'] = $priv_version_ns; |
97 |
|
98 |
// to check again (2.0 (frames?) <-> 3.0) ??? |
99 |
if ($s4y_cfg['browser']['detected_version'] >= 2.0) { |
100 |
$s4y_cfg['browser']['capability_frames'] = true; |
101 |
$s4y_cfg['browser']['capability_tables'] = true; |
102 |
} |
103 |
|
104 |
if ($s4y_cfg['browser']['detected_version'] >= 4.5) { |
105 |
$s4y_cfg['browser']['capability_dhtml'] = true; |
106 |
} |
107 |
|
108 |
// to be done better! |
109 |
if ($s4y_cfg['browser']['detected_version'] >= 4.0) { |
110 |
$s4y_cfg['browser']['capability_swf'] = true; |
111 |
} |
112 |
|
113 |
} |
114 |
|
115 |
// html - Internet Explorer |
116 |
if (strstr ($ua, 'MSIE')) { |
117 |
|
118 |
$MSIEpos = strpos($ua, "MSIE"); |
119 |
$priv_version_ie = trim(substr($ua, $MSIEpos + 4, strpos($ua, ";", $MSIEpos) - $MSIEpos - 4)); |
120 |
|
121 |
$s4y_cfg['browser']['detected_key'] = 'IE'; |
122 |
$s4y_cfg['browser']['detected_name'] = 'Internet Explorer'; |
123 |
$s4y_cfg['browser']['is_msie'] = true; |
124 |
$s4y_cfg['browser']['is_netscape'] = false; |
125 |
$s4y_cfg['browser']['detected_version'] = $priv_version_ie; |
126 |
|
127 |
if ($s4y_cfg['browser']['detected_version'] >= 3.0) { |
128 |
$s4y_cfg['browser']['capability_frames'] = true; |
129 |
$s4y_cfg['browser']['capability_tables'] = true; |
130 |
} |
131 |
|
132 |
if ($s4y_cfg['browser']['detected_version'] >= 4.0) { |
133 |
$s4y_cfg['browser']['capability_dhtml'] = true; |
134 |
|
135 |
$s4y_cfg['browser']['capability_swf'] = true; |
136 |
} |
137 |
|
138 |
} |
139 |
|
140 |
// html - lynx |
141 |
if (strstr ($ua, 'Lynx')) { |
142 |
$s4y_cfg['browser']['capability_frames'] = false; |
143 |
$s4y_cfg['browser']['capability_tables'] = false; |
144 |
} |
145 |
|
146 |
// html - w3m |
147 |
if (strstr ($ua, 'w3m')) { |
148 |
$s4y_cfg['browser']['capability_frames'] = true; |
149 |
$s4y_cfg['browser']['capability_tables'] = true; |
150 |
} |
151 |
|
152 |
|
153 |
// wml - emulator - M3GATE |
154 |
if (strstr ($ua, 'M3GATE')) { |
155 |
$s4y_cfg['browser']['outputType'] = 'wml'; |
156 |
$s4y_cfg['browser']['mime_type'] = 'text/vnd.wap.wml'; |
157 |
|
158 |
// Name/Key bestimmen |
159 |
$spacepos = strpos($ua, ' '); |
160 |
$s4y_cfg['browser']['detected_name'] = $s4y_cfg['browser']['detected_key'] = |
161 |
substr($ua, 0, $spacepos); |
162 |
|
163 |
// Version bestimmen |
164 |
if ($slashpos) { |
165 |
$s4y_cfg['browser']['detected_version'] = |
166 |
substr($ua, $slashpos + 1); |
167 |
} |
168 |
|
169 |
} |
170 |
|
171 |
|
172 |
|
173 |
} |
174 |
|
175 |
|
176 |
function dcsl_BrowserValues_Dump($markuplanguage) { |
177 |
|
178 |
global $s4y_cfg; |
179 |
|
180 |
switch ($markuplanguage) { |
181 |
|
182 |
case 'html': |
183 |
|
184 |
header("Content-Type: text/html\n\n"); |
185 |
print "<html><title>browservalues</title><body>"; |
186 |
print "<br>browservalues:<br>--------------------<br>"; |
187 |
while (list($key, $value) = each($s4y_cfg['browser'])) { |
188 |
print $key . ': ' . $value . "<br>\n"; |
189 |
} |
190 |
|
191 |
break; |
192 |
|
193 |
case 'wml': |
194 |
|
195 |
header( "Content-Type: text/vnd.wap.wml\n\n"); |
196 |
echo "<?xml version=\"1.0\"?> |
197 |
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\"> |
198 |
<wml> |
199 |
<card id=\"start\" title=\"browservalues\"> |
200 |
<p> |
201 |
"; |
202 |
|
203 |
while (list($key, $value) = each($s4y_cfg['browser'])) { |
204 |
print htmlentities ($key . ': ' . $value) . "<br/>"; |
205 |
} |
206 |
|
207 |
echo " |
208 |
</p> |
209 |
</card> |
210 |
</wml> |
211 |
"; |
212 |
|
213 |
break; |
214 |
|
215 |
} |
216 |
|
217 |
exit; |
218 |
|
219 |
} |
220 |
|
221 |
// ================================================ |
222 |
|
223 |
|
224 |
|
225 |
|
226 |
// ================================================ |
227 |
/* |
228 |
for registering JavaScript-Functions |
229 |
at a central handler |
230 |
*/ |
231 |
// ================================================ |
232 |
function php_js_RegisterFunction ($call) |
233 |
{ |
234 |
global $phparray_js_RegisteredFunctions; |
235 |
|
236 |
$newindex = count ($phparray_js_RegisteredFunctions) + 1; |
237 |
|
238 |
$phparray_js_RegisteredFunctions[$newindex] = $call; |
239 |
} |
240 |
|
241 |
function php_js_RegisteredFunctions_2_JavaScriptCode() |
242 |
{ |
243 |
global $phparray_js_RegisteredFunctions; |
244 |
|
245 |
$jscode = ''; |
246 |
for ($i = 0; $i <= count ($phparray_js_RegisteredFunctions); $i++) |
247 |
{ |
248 |
if (isset($phparray_js_RegisteredFunctions[$i])) { |
249 |
$jscode .= $phparray_js_RegisteredFunctions[$i] . "\n"; |
250 |
} |
251 |
} |
252 |
|
253 |
return $jscode; |
254 |
} |
255 |
|
256 |
function php_js_event_bodyOnload() |
257 |
{ |
258 |
?> |
259 |
<script language="javascript"> |
260 |
|
261 |
function js_event_bodyOnload() |
262 |
{ |
263 |
<? |
264 |
print php_js_RegisteredFunctions_2_JavaScriptCode(); |
265 |
|
266 |
?> |
267 |
} |
268 |
|
269 |
</script> |
270 |
|
271 |
<? |
272 |
} |
273 |
|
274 |
|
275 |
// ================================================ |
276 |
/* |
277 |
for writing HTML to the browser which includes some JavaScript-libraries |
278 |
*/ |
279 |
// ================================================ |
280 |
function php_js_writeHTML_IncludeLibraries($cfg) { |
281 |
|
282 |
// -------------------------------- |
283 |
// WDDX-Support |
284 |
if ( |
285 |
isset($cfg['wddx_enabled']) && $cfg['wddx_enabled'] && |
286 |
isset($cfg['wddx_url2dir']) && $cfg['wddx_url2dir'] |
287 |
) { |
288 |
|
289 |
// WDDX-PHP-Support laden |
290 |
if (DEFINED ('MODULE_WDDX')) { |
291 |
print "\n<!-- js_lib_wddx start -->\n"; |
292 |
$wddx_support = new wddx_support; |
293 |
/* |
294 |
WDDX-JavaScript-Support laden |
295 |
(JavaScript-Code in '<script language ="javascript">[...]</script>' eingeschlossen) |
296 |
'JSLib_Include' muss URL auf WDDX-Support-Directory übergeben werden, |
297 |
da der Browser von dort die JavaScript - Dateien anfrägt: |
298 |
$wddx_support -> JSLib_Include ($http_url_to_wddx_directory); |
299 |
*/ |
300 |
$wddx_support -> JSLib_Include ($cfg['wddx_url2dir']); |
301 |
print "\n<!-- js_lib_wddx end -->\n"; |
302 |
} |
303 |
|
304 |
} |
305 |
|
306 |
|
307 |
// -------------------------------- |
308 |
// datasupport (für Datenmanipulationen, etc.) |
309 |
if ( |
310 |
isset($cfg['datasupport']) && $cfg['datasupport'] && |
311 |
isset($cfg['datasupport_url2file']) && $cfg['datasupport_url2file'] |
312 |
) { |
313 |
|
314 |
print "\n<!-- js_lib_datasupport start -->\n"; |
315 |
// JavaScript - Support für Datenmanipulationen laden (jssupport_data.js.inc) |
316 |
?><script language="javascript" src="<? print $cfg['datasupport_url2file']; ?>"></script><? |
317 |
print "\n<!-- js_lib_datasupport end -->\n"; |
318 |
|
319 |
} |
320 |
|
321 |
|
322 |
// -------------------------------- |
323 |
// guisupport (für (dynamische) GUI-Komponenten und den Umgang damit) |
324 |
if ( |
325 |
isset($cfg['guisupport']) && $cfg['guisupport'] && |
326 |
isset($cfg['guisupport_url2file']) && $cfg['guisupport_url2file'] && |
327 |
isset($cfg['guisupport_browserkey']) && $cfg['guisupport_browserkey'] |
328 |
) { |
329 |
|
330 |
print "\n<!-- js_lib_guisupport start -->\n"; |
331 |
// JavaScript - Support für Datenmanipulationen laden (jssupport_data.js.inc) |
332 |
// p|r|o|gressive-media JavaScript Support - GUI function lilbrary |
333 |
?><script language="javascript" src="<? |
334 |
print $cfg['guisupport_url2file'] . '?browserkey=' . $cfg['guisupport_browserkey']; |
335 |
?>"></script><? |
336 |
print "\n<!-- js_lib_guisupport end -->\n"; |
337 |
|
338 |
} |
339 |
|
340 |
|
341 |
|
342 |
} |
343 |
// ================================================ |
344 |
|
345 |
?> |