/[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.7 - (hide annotations)
Sun Sep 5 00:08:43 2004 UTC (20 years ago) by rabit
Branch: MAIN
Changes since 1.6: +66 -37 lines
+ Colour sceme array; U Design/Style.

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

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