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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Sep 3 11:15:42 2004 UTC (20 years ago) by joko
Branch: MAIN
+ initial commit

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

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