/[cvs]/nfo/site/htdocs/inc/otdef/otd_html1/otd_html1.php.inc
ViewVC logotype

Annotation of /nfo/site/htdocs/inc/otdef/otd_html1/otd_html1.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations)
Sun Sep 5 03:21:49 2004 UTC (20 years ago) by rabit
Branch: MAIN
Changes since 1.7: +60 -42 lines
+ Output type related variable encapsulation (moved from "index.php"); U otd_html1_pagefooter(): + param "$extrapageinfocontents"; U otd_html1_pageheader(): + params "$extranavbarcontents" and ''$extratoolbarcontents"; U Design/CSS.

1 rabit 1.1 <?php
2     /*------------------------------------------------------------------------------
3     --- www.netfrag.org
4     --- Setup and common functions include file.
5     --------------------------------------------------------------------------------
6     --- rabit, 21:23 31.08.2004
7 rabit 1.7 --- $Id: otd_html1.php.inc,v 1.6 2004/09/04 03:14:14 rabit Exp $
8 rabit 1.1 ------------------------------------------------------------------------------*/
9    
10     //- REQUIRED:
11     //- common, cms, xmlcp
12    
13     //------------------------------------------------------------------------------
14     //- Name of content render function:
15    
16     $otd_render = 'otd_html1_renderpage';
17    
18     //------------------------------------------------------------------------------
19 rabit 1.7 //- Configuration:
20 rabit 1.1
21 rabit 1.7 //- Colour sceme:
22    
23     $otd_html1['colours'] = array(
24    
25     'bg' => 'white',
26     'text' => 'black',
27    
28     'text2' => '#107080',
29    
30     // Link colours:
31     'a' => '#506040',
32     'a:hover' => '#5060a0',
33     // 'a:visited' => '#506040',
34    
35     // Content colours:
36     'bg11' => '#40d8c0',
37     'bg12' => '#40e8e0',
38     'border1' => '#20a0b0',
39    
40     // Page frame colours:
41     'bg21' => '#a0c090',
42     'bg22' => '#40c8b0',
43     'border2' => '#40a080',
44    
45     );
46 rabit 1.1
47     //------------------------------------------------------------------------------
48 rabit 1.8 //- GET/POST variable encapsulation:
49 rabit 1.1
50 rabit 1.8 if(isset($_GET['debug']))
51     $common_sessiondata['user_prefs']['debug'] = $_GET['debug'];
52    
53     if(isset($_GET['benchlist']))
54     $common_sessiondata['user_prefs']['benchlist'] = $_GET['benchlist'];
55    
56     //------------------------------------------------------------------------------
57 rabit 1.1 //- XMLCP callbacks setup:
58    
59     xmlcp_registertagcallbacks('b', 'otd_html1_cb_xmlcp_start_bold', 'otd_html1_cb_xmlcp_end_bold');
60     xmlcp_registertagcallbacks('h', 'otd_html1_cb_xmlcp_start_headline', 'otd_html1_cb_xmlcp_end_headline');
61     //xmlcp_registertagcallbacks('page', 'otd_html1_cb_xmlcp_start_page', 'otd_html1_cb_xmlcp_end_page');
62     xmlcp_registertagcallbacks('p', 'otd_html1_cb_xmlcp_start_paragraph', 'otd_html1_cb_xmlcp_end_paragraph');
63 joko 1.4 xmlcp_registertagcallbacks('link', 'otd_html1_cb_xmlcp_start_link', 'otd_html1_cb_xmlcp_end_link');
64 rabit 1.1
65 rabit 1.8 //----------------------------------------------------------
66     //- XMLCP callbacks:
67    
68 rabit 1.1 function otd_html1_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) {
69    
70     global $xmlcp_cdata;
71    
72     $xmlcp_cdata .= '<b>';
73    
74     }
75    
76     function otd_html1_cb_xmlcp_end_bold($h_parser, $tagname) {
77    
78     global $xmlcp_cdata;
79    
80     $xmlcp_cdata .= '</b>';
81    
82     }
83    
84     function otd_html1_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) {
85    
86     global $xmlcp_cdata;
87    
88     $xmlcp_cdata = '';
89    
90     }
91    
92     function otd_html1_cb_xmlcp_end_headline($h_parser, $tagname) {
93    
94     global $xmlcp_cdata;
95    
96     otd_html1_headline(trim($xmlcp_cdata));
97    
98     $xmlcp_cdata = '';
99    
100     }
101    
102     /*
103 rabit 1.8 function otd_html1_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { }
104 rabit 1.1
105 rabit 1.8 function otd_html1_cb_xmlcp_end_page($h_parser, $tagname) { }
106 rabit 1.1 */
107    
108     function otd_html1_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) {
109    
110     global $xmlcp_cdata;
111    
112     $xmlcp_cdata = '';
113    
114     }
115    
116     function otd_html1_cb_xmlcp_end_paragraph($h_parser, $tagname) {
117    
118     global $xmlcp_cdata;
119    
120     otd_html1_paragraph(trim($xmlcp_cdata));
121    
122     $xmlcp_cdata = '';
123    
124 joko 1.4 }
125    
126     function otd_html1_cb_xmlcp_start_link($h_parser, $tagname, $attribs) {
127    
128 rabit 1.6 global $xmlcp_cdata;
129    
130     if(isset($attribs['keyname'])) {
131    
132 joko 1.4 $attribs['url'] = common_get_baseurl() . '?ck=' . $attribs['keyname'];
133 rabit 1.6
134 joko 1.4 }
135 rabit 1.6
136     $link = '<a href="' . $attribs['url'] . '">'; // . trim($xmlcp_cdata);
137 joko 1.4
138     $xmlcp_cdata .= $link;
139 rabit 1.6
140 joko 1.4 }
141    
142     function otd_html1_cb_xmlcp_end_link($h_parser, $tagname) {
143 rabit 1.6
144     global $xmlcp_cdata;
145    
146     $xmlcp_cdata .= '</a>';
147    
148 rabit 1.1 }
149    
150 rabit 1.8 //------------------------------------------------------------------------------
151 rabit 1.1 //- Content render functions:
152    
153     function otd_html1_renderpage($keyname, $language_id = 0) {
154    
155 rabit 1.6 global $common, $common_sessiondata;
156 rabit 1.1
157     common_benchmark_addstep('otd_html1: render: start');
158    
159     $list = cms_getlist('xmlpage', $keyname);
160    
161     common_benchmark_addstep('otd_html1: render: CMS get list');
162    
163     $contentdata = cms_getcontent('xmlpage', $keyname, $language_id);
164    
165     common_benchmark_addstep('otd_html1: render: CMS get content');
166    
167     $xml = $contentdata['content'];
168    
169 rabit 1.2 otd_html1_pagehead();
170    
171     common_benchmark_addstep('otd_html1: render: head');
172    
173 rabit 1.8 otd_html1_pageheader('', '&bull; <a href="' . common_get_baseurl() . 'pages/otd_html1/userinfo.php">User info</a>');
174 rabit 1.1
175     common_benchmark_addstep('otd_html1: render: header');
176    
177     if($xml) {
178    
179     $titledata = '';
180    
181     for($i = 0; $i < count($list); $i++) {
182    
183 rabit 1.8 $imgtag = otd_html1_get_imgtag('icons/flags/' . $list[$i][3] . '.gif', $list[$i][4], 14, 21);
184 rabit 1.1
185 rabit 1.8 $titledata .= (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '" title="' . $list[$i][4] . '">' . $imgtag . '</a>') . '&nbsp;';
186 rabit 1.1
187     }
188    
189     otd_html1_pagetitle($contentdata['description'], $titledata . '<br />');
190    
191 rabit 1.2 $res = xmlcp_parse($xml);
192 rabit 1.1
193 rabit 1.3 common_benchmark_addstep('otd_html1: render: xmlcp_parse() = ' . $res);
194 rabit 1.1
195 rabit 1.6 // Only show debug outputs when set as preference:
196     if($common_sessiondata['user_prefs']['debug']) {
197 rabit 1.1
198 rabit 1.6 otd_html1_headline('Content list array:');
199 rabit 1.3 otd_html1_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true))));
200 rabit 1.1
201 rabit 1.6 otd_html1_headline('Content query result array:');
202 rabit 1.3 otd_html1_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true))));
203 rabit 1.1
204 rabit 1.6 otd_html1_headline('User preferences array:');
205     otd_html1_codeparagraph('$common_sessiondata[user_prefs] = ' . nl2br(htmlentities(print_r($common_sessiondata['user_prefs'], true))));
206 rabit 1.1
207 rabit 1.3 }
208    
209 rabit 1.8 $extrapageinfocontents = 'Content item "<b>' . $contentdata['description'] . '</b>" (language: "<b>' . $contentdata['language_name'] . '</b>") created by <b>' . $contentdata['creator_name'] . '</b> on <b>' . date('Y/m/d, H:i:s', $contentdata['unixtime']) . '</b>. Last changes by <b>' . $contentdata['creator_name'] . '</b> on <b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>.<br />
210     Page created by <b>rabit</b> on <b>2004/08/31, 21:23</b>.
211     ';
212 rabit 1.1
213     } else {
214    
215     otd_html1_pagetitle('Bad content request');
216    
217 rabit 1.6 otd_html1_paragraph('Sorry, but the requested content is unknown. Please check your query and if the problem occours again try to contact a site administrator.');
218 rabit 1.1
219     }
220    
221     common_benchmark_addstep('otd_html1: render: content');
222    
223 rabit 1.8 otd_html1_pagefooter($extrapageinfocontents);
224 rabit 1.1
225 rabit 1.2 common_benchmark_addstep('otd_html1: render: footer');
226    
227     otd_html1_pagefoot();
228    
229 rabit 1.1 }
230    
231 rabit 1.8 //------------------------------------------------------------------------------
232 rabit 1.6 //- HTML return functions:
233    
234     function otd_html1_get_imgtag($relativeurl, $alt, $height = '', $width = '') {
235    
236     global $common;
237    
238     return '<img alt="' . $alt . '" src="' . $common['site']['gfxurl'] . $relativeurl . '" style="border:0;' . ($height ? ' height:' . $height . 'px;' : '') . ($width ? ' width:' . $width . 'px;' : '') . '" />';
239    
240     }
241    
242 rabit 1.8 //------------------------------------------------------------------------------
243 rabit 1.6 //- HTML output functions:
244 rabit 1.1
245     function otd_html1_authbox() {
246    
247     global $common_sessiondata;
248    
249 rabit 1.2 $boxheight = 48;
250 rabit 1.7 $boxwidth = 240;
251 rabit 1.2
252 rabit 1.6 if($common_sessiondata['user_auth']['authorised']) {
253 rabit 1.2
254     echo '<table cellspacing="0" cellpadding="2" class="f22" width="' . $boxwidth . '">
255 rabit 1.1 <tr>
256 rabit 1.7 <th class="box2" height="' . $boxheight . '" width="40"><b>User<br />login</b></th>
257 rabit 1.3 <td align="center" valign="top" style="padding:4px;">
258 rabit 1.2 <small>
259 rabit 1.6 You are logged in the ' . $common_sessiondata['user_auth']['logincount'] . '. time as <b>' . $common_sessiondata['user_auth']['name'] . '</b>. Login time was <b>' . date('H:i:s, d.m.Y', $common_sessiondata['user_auth']['logintime']) . '</b>.<br/ >
260     Your rights are "<b>' . $common_sessiondata['user_auth']['rights'] . '</b>".
261 rabit 1.2 </small>
262     </td>
263     </table>
264     ';
265    
266     } else {
267    
268 rabit 1.7 echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="margin:0;">
269 rabit 1.2 <table cellspacing="0" cellpadding="0" class="f22" width="' . $boxwidth . '">
270     <tr>
271 rabit 1.7 <th class="box2" height="' . $boxheight . '" rowspan="2" width="40"><b>User<br />login</b></th>
272 rabit 1.2 <td align="right">User name:</td>
273 rabit 1.1 <td rowspan="2">&nbsp;</td>
274 rabit 1.7 <td><input name="un" size="8" type="text" tabindex="1" /></td>
275 rabit 1.5 <th class="box2" rowspan="2"><input type="submit" value="OK" tabindex="3" /></th>
276 rabit 1.1 </tr>
277     <tr>
278 rabit 1.7 <td align="right">Password:</td><td><input name="pw" size="8" type="password" tabindex="2" /></td>
279 rabit 1.1 </tr>
280     </table>
281     </form>
282     ';
283    
284 rabit 1.2 }
285    
286 rabit 1.1 }
287    
288 rabit 1.2 function otd_html1_benchmarkbox() {
289    
290     global $common;
291 rabit 1.1
292 rabit 1.2 $contents = '';
293    
294     for($i = 0; $i < count($common['benchmark']); $i++) {
295 rabit 1.1
296 rabit 1.2 $mtimesegs = explode(' ', $common['benchmark'][$i][1]);
297     $contents .= substr('0' . ($i + 1), -2) . ': "<b>' . $common['benchmark'][$i][0] . '</b>": ';
298 rabit 1.1
299 rabit 1.2 if($i) {
300 rabit 1.1
301 rabit 1.2 $timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]);
302     $timediff += $mtimesegs[0] - $lastmtimesegs[0];
303 rabit 1.1
304 rabit 1.2 $contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br />
305 rabit 1.1 ';
306    
307 rabit 1.2 } else {
308 rabit 1.1
309 rabit 1.2 $contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br />
310     ';
311 rabit 1.1
312 rabit 1.2 }
313 rabit 1.1
314 rabit 1.2 $lastmtimesegs = $mtimesegs;
315 rabit 1.1
316 rabit 1.2 }
317 rabit 1.1
318 rabit 1.2 otd_html1_paragraph('<small>
319     <b>Partial execution times:</b><br />
320     <br />
321 rabit 1.3 ' . $contents . '</small>', 'box1');
322 rabit 1.1
323 rabit 1.2 }
324 rabit 1.1
325 rabit 1.2 function otd_html1_codeparagraph($contents) {
326 rabit 1.1
327 rabit 1.3 echo '<p align="justify" class="hl12">
328 rabit 1.2 <code>
329     ' . $contents . '
330     </code>
331     </p>
332 rabit 1.1 ';
333    
334 rabit 1.2 }
335 rabit 1.1
336 rabit 1.2 function otd_html1_headline($caption) {
337    
338 rabit 1.8 global $otd_html1;
339    
340     echo '<p style="border-bottom:1px solid ' . $otd_html1['colours']['border1'] . '; padding-bottom:1px;">
341     <b>' . $caption . '</b>
342     </p>
343 rabit 1.1 ';
344    
345 rabit 1.2 }
346    
347     function otd_html1_pagefoot() {
348 rabit 1.1
349 rabit 1.8 global $common_sessiondata;
350    
351     // As last show the benchmark list when set as preference:
352     if($common_sessiondata['user_prefs']['benchlist']) {
353    
354     otd_html1_benchmarkbox();
355    
356     }
357    
358 rabit 1.2 echo '</body>
359 rabit 1.1
360 rabit 1.2 </html>
361     ';
362 rabit 1.1
363 rabit 1.2 }
364 rabit 1.1
365 rabit 1.8 function otd_html1_pagefooter($extrapageinfocontents = '') {
366 rabit 1.1
367 rabit 1.8 global $common, $ID;
368 rabit 1.1
369 rabit 1.7 $contentheight = 240; // Minimum height of content and navigation.
370    
371 rabit 1.1 $endmtimesegs = explode(' ', microtime());
372     $startmtimesegs = explode(' ', $common['benchmark'][0][1]);
373     $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);
374     $timediff += $endmtimesegs[0] - $startmtimesegs[0];
375    
376 rabit 1.8 otd_html1_paragraph('<small>
377     ' . ($extrapageinfocontents ? $extrapageinfocontents . '<br />
378     ' : '') . 'CVS ID: "<b>' . $ID . '</b>"
379     </small>', 'box1');
380    
381 rabit 1.2 echo '</td>
382 rabit 1.6 <td class="bg11" style="padding:0;">
383 rabit 1.7 ' . otd_html1_get_imgtag('blank.gif', '', $contentheight, 8) . '
384 rabit 1.1 </td>
385     </tr>
386 rabit 1.2 <tr class="bg11">
387     <td align="center">
388     <small>
389     Page execution time:<br />
390     </small>
391     <code>' . round($timediff * 100000) / 100 . '</code> ms.<br />
392     </td>
393 rabit 1.8 <td align="center" colspan="2">
394     <a href="http://validator.w3.org/check?uri=referer" target="_blank"><img alt="This page is valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10" style="border:0;width:88px;height:31px;" /></a>&nbsp;&nbsp;&nbsp;<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img style="border:0;width:88px;height:31px;" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
395 rabit 1.1 </td>
396     </tr>
397     </table>
398     ';
399    
400     }
401    
402 rabit 1.2 function otd_html1_pagehead() {
403 rabit 1.1
404 rabit 1.7 global $otd_html1;
405    
406 rabit 1.1 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
407    
408     <html xmlns="http://www.w3.org/1999/xhtml">
409    
410     <head>
411     <title>www.netfrag.org</title>
412     <style type="text/css"><!--
413 rabit 1.7 a { color:' . $otd_html1['colours']['a'] . '; font-weight:bold; text-decoration:none; }
414     a:hover { color:' . $otd_html1['colours']['a:hover'] . '; }
415     body { background-color:' . $otd_html1['colours']['bg'] . '; color:' . $otd_html1['colours']['text'] . '; margin:0; }
416     body, input, table { font: 8pt verdana, serif; }
417 rabit 1.1 input { border:1px; }
418 rabit 1.7 .bg11, .f11, .hl11 { background-color:' . $otd_html1['colours']['bg11'] . '; }
419     .bg12, .box1, .f12, .hl12 { background-color:' . $otd_html1['colours']['bg12'] . '; }
420     .bg21, .box2, .f21, .hl21 { background-color:' . $otd_html1['colours']['bg21'] . '; }
421     .bg22, .f22, .hl22 { background-color:' . $otd_html1['colours']['bg22'] . '; }
422     .box1, .f11, .f12 { border:1px solid ' . $otd_html1['colours']['border1'] . '; }
423     .box2, .f21, .f22 { border:1px solid ' . $otd_html1['colours']['border2'] . '; }
424     .box1, .box2, .hl11, .hl12, .hl21, .hl22 { padding:4px; }
425     .c2 { color:' . $otd_html1['colours']['text2'] . '; }
426 rabit 1.1 --></style>
427     </head>
428    
429     <body>
430     ';
431    
432     }
433    
434 rabit 1.8 function otd_html1_pageheader($extranavbarcontents = '', $extratoolbarcontents = '') {
435 rabit 1.1
436 rabit 1.7 global $common_sessiondata, $otd_html1, $request_contentkey;
437 rabit 1.6
438 rabit 1.7 $leftbarwidth = 144; // Inner width (w/o padding) of left bar.
439 rabit 1.6
440     $benchlist = $common_sessiondata['user_prefs']['benchlist'];
441     $debug = $common_sessiondata['user_prefs']['debug'];
442    
443 rabit 1.7 $urlprefix = $_SERVER['PATH_INFO'] . '?ck=' . $request_contentkey . '&';
444    
445     echo '<table cellspacing="0" cellpadding="8" style="border-bottom:2px solid ' . $otd_html1['colours']['border2'] . '; border-top:2px solid ' . $otd_html1['colours']['border2'] . '; width:100%;">
446 rabit 1.2 <tr>
447     <td class="bg11" colspan="3">
448 rabit 1.6 <table cellspacing="0" cellpadding="0" style="width:100%">
449 rabit 1.1 <tr class="bg11">
450 rabit 1.2 <th width="100%">
451     <span style="border-bottom:2px solid black; font-size:24pt; letter-spacing:-2pt; padding-bottom:3px;">
452 rabit 1.7 www.<span class="c2">n</span>et<span class="c2">f</span>rag.<span class="c2">o</span>rg</span>
453     <p style="margin-top:6px;">
454 rabit 1.2 <small>NetFrag and friends</small>
455     </p>
456 rabit 1.1 </th>
457 rabit 1.7 <td>
458     ' . otd_html1_get_imgtag('blank.gif', '', 1, 8) . '
459     </td>
460 rabit 1.2 <td>
461 rabit 1.1 ';
462    
463     otd_html1_authbox();
464    
465     echo '</td>
466     </tr>
467 rabit 1.2 </table>
468     </td>
469     </tr>
470     <tr>
471 rabit 1.7 <td class="bg11" style="border-top:2px solid ' . $otd_html1['colours']['border1'] . ';" valign="top">
472 rabit 1.8 <div class="box2" style="margin-bottom:16px;"><big><b>N</b>a<b>F</b>igati<b>o</b>n:</big></div>
473 rabit 1.7 <div style="margin-bottom:32px;">
474 rabit 1.8 &bull; <a href="' . common_get_baseurl() . '">Home page</a><br />
475 rabit 1.6 ' . otd_html1_get_imgtag('blank.gif', '', 1, $leftbarwidth) . '
476 rabit 1.7 </div>
477 rabit 1.8 <div class="box2" style="margin-bottom:16px;"><big>Info &amp; tools:</big></div>
478     ' . ($extratoolbarcontents ? $extratoolbarcontents . '<br />
479     <br />
480     ' : '') . '&bull; Benchmark list: [<a href="' . $urlprefix . 'benchlist=' . ($benchlist ? '0">off' : '1">on') . '</a>]<br />
481 rabit 1.7 &bull; Debug outputs: [<a href="' . $urlprefix . 'debug=' . ($debug ? '0">off' : '1">on') . '</a>]<br />
482 rabit 1.1 </td>
483 rabit 1.6 <td style="border:2px solid #3090a8; padding:8px;" valign="top">
484 rabit 1.2 ';
485    
486     }
487 rabit 1.1
488 rabit 1.8 function otd_html1_pagetitle($title, $extracontents = '') {
489 rabit 1.1
490 rabit 1.8 echo '<table cellspacing="0" cellpadding="4" class="box1" style="width:100%;">
491     <tr>
492     <td><big><b>&bull; ' . $title . '</b>&nbsp;</big></td>
493     <td align="right">' . ($extracontents ? $extracontents : '') . '</td>
494     </tr>
495     </table>
496 rabit 1.1 ';
497    
498     }
499    
500     function otd_html1_paragraph($contents, $class = '') {
501    
502     echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '>
503     ' . $contents . '
504     </p>
505     ';
506    
507     }
508    
509     //------------------------------------------------------------------------------
510    
511     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed