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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (show annotations)
Fri Sep 10 21:30:50 2004 UTC (20 years ago) by rabit
Branch: MAIN
CVS Tags: HEAD
Changes since 1.13: +33 -10 lines
+ Support for "code" entity in xmlpage (XMLCP callback functions); + Direct link to NQL definition page; U otd_html1_codeparagraph().

1 <?php
2 /*------------------------------------------------------------------------------
3 --- www.netfrag.org
4 --- Setup and common functions include file.
5 --------------------------------------------------------------------------------
6 --- rabit, 21:23 31.08.2004
7 --- $Id: otd_html1.php.inc,v 1.13 2004/09/06 02:56:40 rabit Exp $
8 ------------------------------------------------------------------------------*/
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 //- Configuration:
20
21 //- 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' => '#20a0c0',
39
40 // Page frame colours:
41 'bg21' => '#a0c090',
42 'bg22' => '#40c8b0',
43 'border2' => '#40a080',
44
45 );
46
47 //------------------------------------------------------------------------------
48 //- Authorisation via HTTP:
49
50 if(isset($_POST['un']) && isset($_POST['pw'])) {
51
52 common_authorise($_POST['un'], $_POST['pw']);
53
54 common_benchmark_addstep('otd_html1: authorisation test');
55
56 }
57
58 //------------------------------------------------------------------------------
59 //- GET/POST variable encapsulation:
60
61 if(isset($_GET['debug']))
62 $common_sessiondata['user_prefs']['debug'] = $_GET['debug'];
63
64 if(isset($_GET['benchlist']))
65 $common_sessiondata['user_prefs']['benchlist'] = $_GET['benchlist'];
66
67 //------------------------------------------------------------------------------
68 //- XMLCP callbacks setup:
69
70 xmlcp_registertagcallbacks('b', 'otd_html1_cb_xmlcp_start_bold', 'otd_html1_cb_xmlcp_end_bold');
71 xmlcp_registertagcallbacks('br', 'otd_html1_cb_xmlcp_break');
72 xmlcp_registertagcallbacks('code', 'otd_html1_cb_xmlcp_start_code', 'otd_html1_cb_xmlcp_end_code');
73 xmlcp_registertagcallbacks('h', 'otd_html1_cb_xmlcp_start_headline', 'otd_html1_cb_xmlcp_end_headline');
74 //xmlcp_registertagcallbacks('page', 'otd_html1_cb_xmlcp_start_page', 'otd_html1_cb_xmlcp_end_page');
75 xmlcp_registertagcallbacks('p', 'otd_html1_cb_xmlcp_start_paragraph', 'otd_html1_cb_xmlcp_end_paragraph');
76 xmlcp_registertagcallbacks('link', 'otd_html1_cb_xmlcp_start_link', 'otd_html1_cb_xmlcp_end_link');
77
78 //----------------------------------------------------------
79 //- XMLCP callbacks:
80
81 function otd_html1_cb_xmlcp_break($h_parser, $tagname, $attribs) {
82
83 global $xmlcp_cdata;
84
85 $xmlcp_cdata .= '<br />';
86
87 }
88
89 function otd_html1_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) {
90
91 global $xmlcp_cdata;
92
93 $xmlcp_cdata .= '<b>';
94
95 }
96
97 function otd_html1_cb_xmlcp_end_bold($h_parser, $tagname) {
98
99 global $xmlcp_cdata;
100
101 $xmlcp_cdata .= '</b>';
102
103 }
104
105 function otd_html1_cb_xmlcp_start_code($h_parser, $tagname, $attribs) {
106
107 global $xmlcp_cdata;
108
109 $xmlcp_cdata = '';
110
111 }
112
113 function otd_html1_cb_xmlcp_end_code($h_parser, $tagname) {
114
115 global $xmlcp_cdata;
116
117 otd_html1_codeparagraph(trim($xmlcp_cdata));
118
119 $xmlcp_cdata = '';
120
121 }
122
123 function otd_html1_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) {
124
125 global $xmlcp_cdata;
126
127 $xmlcp_cdata = '';
128
129 }
130
131 function otd_html1_cb_xmlcp_end_headline($h_parser, $tagname) {
132
133 global $xmlcp_cdata;
134
135 otd_html1_headline(trim($xmlcp_cdata));
136
137 $xmlcp_cdata = '';
138
139 }
140
141 /*
142 function otd_html1_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { }
143
144 function otd_html1_cb_xmlcp_end_page($h_parser, $tagname) { }
145 */
146
147 function otd_html1_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) {
148
149 global $xmlcp_cdata;
150
151 $xmlcp_cdata = '';
152
153 }
154
155 function otd_html1_cb_xmlcp_end_paragraph($h_parser, $tagname) {
156
157 global $xmlcp_cdata;
158
159 otd_html1_paragraph(trim($xmlcp_cdata));
160
161 $xmlcp_cdata = '';
162
163 }
164
165 function otd_html1_cb_xmlcp_start_link($h_parser, $tagname, $attribs) {
166
167 global $xmlcp_cdata;
168
169 if(isset($attribs['keyname'])) {
170
171 $attribs['url'] = common_get_baseurl() . '?ck=' . $attribs['keyname'];
172
173 }
174
175 $target = '';
176 if(isset($attribs['show']) && ($attribs['show'] == 'new')) {
177 $target = 'target="_blank"';
178 }
179
180 $link = '<a ' . $target . ' href="' . $attribs['url'] . '">'; // . trim($xmlcp_cdata);
181
182 $xmlcp_cdata .= $link;
183
184 }
185
186 function otd_html1_cb_xmlcp_end_link($h_parser, $tagname) {
187
188 global $xmlcp_cdata;
189
190 $xmlcp_cdata .= '</a>';
191
192 }
193
194 //------------------------------------------------------------------------------
195 //- Content render functions:
196
197 function otd_html1_renderpage($keyname, $language_id = 0) {
198
199 global $common, $common_sessiondata;
200
201 common_benchmark_addstep('otd_html1: render: start');
202
203 $list = cms_getlist('xmlpage', $keyname);
204
205 common_benchmark_addstep('otd_html1: render: CMS get list');
206
207 $contentdata = cms_getcontent('xmlpage', $keyname, $language_id);
208
209 common_benchmark_addstep('otd_html1: render: CMS get content');
210
211 $xml = $contentdata['content'];
212
213 otd_html1_pagehead();
214
215 common_benchmark_addstep('otd_html1: render: head');
216
217 $navbarcontent = '&bull; <a href="' . common_get_baseurl() . 'pages/otd_html1/userinfo.php">CMS test page</a>';
218
219 otd_html1_pageheader($navbarcontent);
220
221 common_benchmark_addstep('otd_html1: render: header');
222
223 if($xml) {
224
225 $titledata = '';
226
227 for($i = 0; $i < count($list); $i++) {
228
229 $imgtag = otd_html1_get_imgtag('icons/flags/' . $list[$i][3] . '.gif', $list[$i][4], 14, 21);
230
231 $titledata .= (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '" title="' . $list[$i][4] . '">' . $imgtag . '</a>') . '&nbsp;';
232
233 }
234
235 otd_html1_pagetitle($contentdata['description'], $titledata . '<br />');
236
237 $res = xmlcp_parse($xml);
238
239 common_benchmark_addstep('otd_html1: render: xmlcp_parse() = ' . $res);
240
241 // Only show debug outputs when set as preference:
242 if($common_sessiondata['user_prefs']['debug']) {
243
244 otd_html1_headline('Content list array:');
245 otd_html1_codeparagraph('$list = ' . trim(htmlentities(print_r($list, true))));
246
247 /*
248 otd_html1_headline('Content query result array:');
249 otd_html1_codeparagraph('$contentdata = ' . trim(htmlentities(print_r($contentdata, true))));
250 */
251
252 otd_html1_headline('User preferences array:');
253 otd_html1_codeparagraph('$common_sessiondata[user_prefs] = ' . trim(htmlentities(print_r($common_sessiondata['user_prefs'], true))));
254
255 }
256
257 $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 />
258 Page created by <b>rabit</b> on <b>2004/08/31, 21:23</b>.
259 ';
260
261 } else {
262
263 otd_html1_pagetitle('Bad content request');
264
265 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.');
266
267 }
268
269 common_benchmark_addstep('otd_html1: render: content');
270
271 otd_html1_pagefooter($extrapageinfocontents);
272
273 common_benchmark_addstep('otd_html1: render: footer');
274
275 otd_html1_pagefoot();
276
277 }
278
279 //------------------------------------------------------------------------------
280 //- HTML return functions:
281
282 function otd_html1_get_imgtag($relativeurl, $alt, $height = '', $width = '') {
283
284 global $common;
285
286 return '<img alt="' . $alt . '" src="' . $common['site']['gfxurl'] . $relativeurl . '" style="border:0;' . ($height ? ' height:' . $height . 'px;' : '') . ($width ? ' width:' . $width . 'px;' : '') . '" />';
287
288 }
289
290 //------------------------------------------------------------------------------
291 //- HTML output functions:
292
293 function otd_html1_authbox() {
294
295 global $common_sessiondata;
296
297 $boxheight = 48;
298 $boxwidth = 240;
299
300 if($common_sessiondata['user_auth']['authorised']) {
301
302 echo '<table cellspacing="0" cellpadding="2" class="f22" width="' . $boxwidth . '">
303 <tr>
304 <th class="box2" height="' . $boxheight . '" width="40"><b>User<br />login</b></th>
305 <td align="center" valign="top" style="padding:4px;">
306 <small>
307 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/ >
308 Your rights are "<b>' . $common_sessiondata['user_auth']['rights'] . '</b>".
309 </small>
310 </td>
311 </table>
312 ';
313
314 } else {
315
316 echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="margin:0;">
317 <table cellspacing="0" cellpadding="0" class="f22" width="' . $boxwidth . '">
318 <tr>
319 <th class="box2" height="' . $boxheight . '" rowspan="2" width="40"><b>User<br />login</b></th>
320 <td align="right">User name:</td>
321 <td rowspan="2">&nbsp;</td>
322 <td><input name="un" size="8" type="text" tabindex="1" /></td>
323 <th class="box2" rowspan="2"><input type="submit" value="OK" tabindex="3" /></th>
324 </tr>
325 <tr>
326 <td align="right">Password:</td><td><input name="pw" size="8" type="password" tabindex="2" /></td>
327 </tr>
328 </table>
329 </form>
330 ';
331
332 }
333
334 }
335
336 function otd_html1_benchmarkbox() {
337
338 global $common;
339
340 $contents = '';
341
342 for($i = 0; $i < count($common['benchmark']); $i++) {
343
344 $mtimesegs = explode(' ', $common['benchmark'][$i][1]);
345 $contents .= substr('0' . ($i + 1), -2) . ': "<b>' . $common['benchmark'][$i][0] . '</b>": ';
346
347 if($i) {
348
349 $timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]);
350 $timediff += $mtimesegs[0] - $lastmtimesegs[0];
351
352 $contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br />
353 ';
354
355 } else {
356
357 $contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br />
358 ';
359
360 }
361
362 $lastmtimesegs = $mtimesegs;
363
364 }
365
366 otd_html1_paragraph('<small>
367 <b>Partial execution times:</b><br />
368 <br />
369 ' . $contents . '</small>', 'box1');
370
371 }
372
373 function otd_html1_codeparagraph($contents) {
374
375 echo '<p align="justify" class="hl12" style="white-space:pre;">
376 <code>' . $contents . '</code>
377 </p>
378 ';
379
380 }
381
382 function otd_html1_headline($caption) {
383
384 global $otd_html1;
385
386 echo '<p><span style="border-bottom:1px solid ' . $otd_html1['colours']['border1'] . '; padding-bottom:1px;"><b>' . $caption . '</b></span></p>
387 ';
388
389 }
390
391 function otd_html1_pagefoot() {
392
393 global $common_sessiondata;
394
395 // As last show the benchmark list when set as preference:
396 if($common_sessiondata['user_prefs']['benchlist']) {
397
398 otd_html1_benchmarkbox();
399
400 }
401
402 echo '</body>
403
404 </html>
405 ';
406
407 }
408
409 function otd_html1_pagefooter($extrapageinfocontents = '') {
410
411 global $common, $ID;
412
413 $contentheight = 240; // Minimum height of content and navigation.
414
415 $endmtimesegs = explode(' ', microtime());
416 $startmtimesegs = explode(' ', $common['benchmark'][0][1]);
417 $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);
418 $timediff += $endmtimesegs[0] - $startmtimesegs[0];
419
420 otd_html1_paragraph('<small>
421 ' . ($extrapageinfocontents ? $extrapageinfocontents . '<br />
422 ' : '') . 'CVS ID: "<b>' . $ID . '</b>"
423 </small>', 'box1');
424
425 echo '</td>
426 <td class="bg11" style="padding:0;">
427 ' . otd_html1_get_imgtag('blank.gif', '', $contentheight, 8) . '
428 </td>
429 </tr>
430 <tr class="bg11">
431 <td align="center">
432 <small>
433 Page execution time:<br />
434 </small>
435 <code>' . round($timediff * 100000) / 100 . '</code> ms.<br />
436 </td>
437 <td align="center" colspan="2">
438 <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>
439 </td>
440 </tr>
441 </table>
442 ';
443
444 }
445
446 function otd_html1_pagehead() {
447
448 global $otd_html1;
449
450 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
451
452 <html xmlns="http://www.w3.org/1999/xhtml">
453
454 <head>
455 <title>www.netfrag.org</title>
456 <style type="text/css"><!--
457 a { color:' . $otd_html1['colours']['a'] . '; font-weight:bold; text-decoration:none; }
458 a:hover { color:' . $otd_html1['colours']['a:hover'] . '; }
459 body { background-color:' . $otd_html1['colours']['bg'] . '; color:' . $otd_html1['colours']['text'] . '; margin:0; }
460 body, input, select, table, textarea { font: 8pt verdana, serif; }
461 input, select, textarea { border:1px; }
462 .bb1 { background-color:' . $otd_html1['colours']['border1'] . '; }
463 .bb2 { background-color:' . $otd_html1['colours']['border2'] . '; }
464 .bg11, .f11, .hl11 { background-color:' . $otd_html1['colours']['bg11'] . '; }
465 .bg12, .box1, .f12, .hl12 { background-color:' . $otd_html1['colours']['bg12'] . '; }
466 .bg21, .box2, .f21, .hl21 { background-color:' . $otd_html1['colours']['bg21'] . '; }
467 .bg22, .f22, .hl22 { background-color:' . $otd_html1['colours']['bg22'] . '; }
468 .box1, .f11, .f12 { border:1px solid ' . $otd_html1['colours']['border1'] . '; }
469 .box2, .f21, .f22 { border:1px solid ' . $otd_html1['colours']['border2'] . '; }
470 .box1, .box2, .hl11, .hl12, .hl21, .hl22 { padding:4px; }
471 .c2 { color:' . $otd_html1['colours']['text2'] . '; }
472 --></style>
473 </head>
474
475 <body>
476 ';
477
478 }
479
480 function otd_html1_pageheader($extranavbarcontents = '', $extratoolbarcontents = '') {
481
482 global $common, $common_sessiondata, $otd_html1, $request_contentkey;
483
484 $leftbarwidth = 144; // Inner width (w/o padding) of left bar.
485
486 $benchlist = $common_sessiondata['user_prefs']['benchlist'];
487 $debug = $common_sessiondata['user_prefs']['debug'];
488
489 $urlprefix = $_SERVER['PATH_INFO'] . '?ck=' . $request_contentkey . '&';
490 // $urlprefix = $common['page']['filename'] . '?ck=' . $request_contentkey . '&';
491
492 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%;">
493 <tr>
494 <td class="bg11" colspan="3">
495 <table cellspacing="0" cellpadding="0" style="width:100%">
496 <tr class="bg11">
497 <th width="100%">
498 <span style="border-bottom:2px solid black; font-size:22pt; letter-spacing:-2pt; padding-bottom:3px;">
499 www.<span class="c2">N</span>et<span class="c2">F</span>rag.<span class="c2">o</span>rg</span>
500 <p style="margin-top:6px;">
501 <small>NetFrag and friends</small>
502 </p>
503 </th>
504 <td>
505 ' . otd_html1_get_imgtag('blank.gif', '', 1, 8) . '
506 </td>
507 <td>
508 ';
509
510 otd_html1_authbox();
511
512 echo '</td>
513 </tr>
514 </table>
515 </td>
516 </tr>
517 <tr>
518 <td class="bg11" style="border-top:2px solid ' . $otd_html1['colours']['border1'] . ';" valign="top">
519 <div class="box2" style="margin-bottom:16px;"><big><b>N</b>a<b>F</b>igati<b>o</b>n:</big></div>
520 <div style="margin-bottom:32px;">
521 &bull; <a href="' . common_get_baseurl() . '">Home page</a><br />
522 &bull; <a href="' . common_get_baseurl() . '?ck=NQL_def">NQL definition</a><br />
523 ' . ($extranavbarcontents ? '<br />
524 ' . $extranavbarcontents . '<br />
525 ' : '') . otd_html1_get_imgtag('blank.gif', '', 1, $leftbarwidth) . '
526 </div>
527 <div class="box2" style="margin-bottom:16px;"><big>Info &amp; tools:</big></div>
528 ' . ($extratoolbarcontents ? $extratoolbarcontents . '<br />
529 <br />
530 ' : '') . '&bull; Benchmark list: [<a href="' . $urlprefix . 'benchlist=' . ($benchlist ? '0">off' : '1">on') . '</a>]<br />
531 &bull; Debug outputs: [<a href="' . $urlprefix . 'debug=' . ($debug ? '0">off' : '1">on') . '</a>]<br />
532 </td>
533 <td style="border:2px solid ' . $otd_html1['colours']['border1'] . '; padding:8px;" valign="top">
534 ';
535
536 }
537
538 function otd_html1_pagetitle($title, $extracontents = '') {
539
540 echo '<table cellspacing="0" cellpadding="4" class="box1" style="width:100%;">
541 <tr>
542 <td><big><b>&bull; ' . $title . '</b>&nbsp;</big></td>
543 <td align="right">' . ($extracontents ? $extracontents : '') . '</td>
544 </tr>
545 </table>
546 ';
547
548 }
549
550 function otd_html1_paragraph($contents, $class = '') {
551
552 echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '>
553 ' . $contents . '
554 </p>
555 ';
556
557 }
558
559 function otd_html1_table($columnnames, $rows) {
560
561 echo '<table cellpadding="4" cellspacing="1" class="bb1">
562 <tr class="bg11">
563 ';
564
565 for($x = 0; $x < count($columnnames); $x++) {
566
567 echo '<th>' . $columnnames[$x] . '</th>';
568
569 }
570
571 echo '
572 </tr>
573 ';
574
575 for($y = 0; $y < count($rows); $y++) {
576
577 echo '<tr class="bg12">
578 ';
579
580 for($x = 0; $x < count($columnnames); $x++) {
581
582 echo '<td>' . $rows[$y][$x] . '</td>
583 ';
584
585 }
586
587 echo '</tr>
588 ';
589
590 }
591
592 echo '</table>
593 ';
594
595 }
596
597 //------------------------------------------------------------------------------
598
599 ?>

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