/[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.2 - (hide annotations)
Fri Sep 3 22:46:59 2004 UTC (20 years ago) by joko
Branch: MAIN
CVS Tags: alpha-20040904-1, HEAD
Changes since 1.1: +35 -2 lines
+ link functionality: function otd_html1_cb_xmlcp_start|end_link
+ function otd_wml1_link

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

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