/[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.6 - (hide annotations)
Sat Sep 4 03:14:14 2004 UTC (20 years ago) by rabit
Branch: MAIN
CVS Tags: alpha-20040904-1
Changes since 1.5: +68 -51 lines
+ Function: otd_html1_get_imgtag(); + "benchlist" and "debug" switches; U "link" callback functions modified; U Debug outputs; U Design/Style; - "devstate" switch.

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

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