/[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.4 - (hide annotations)
Fri Sep 3 22:46:17 2004 UTC (20 years ago) by joko
Branch: MAIN
Changes since 1.3: +18 -1 lines
+ link functionality: function otd_html1_cb_xmlcp_start|end_link

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

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