/[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.1 - (hide annotations)
Wed Sep 1 20:43:44 2004 UTC (20 years ago) by rabit
Branch: MAIN
2. Initial commit (renamed): seperated HTML and output functions taken from common include file.

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     --- $Id: ot_html1.php.inc,v 1.1 2004/09/01 08:53:08 rabit Exp $
8     ------------------------------------------------------------------------------*/
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    
32     function otd_html1_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) {
33    
34     global $xmlcp_cdata;
35    
36     $xmlcp_cdata .= '<b>';
37    
38     }
39    
40     function otd_html1_cb_xmlcp_end_bold($h_parser, $tagname) {
41    
42     global $xmlcp_cdata;
43    
44     $xmlcp_cdata .= '</b>';
45    
46     }
47    
48     function otd_html1_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) {
49    
50     global $xmlcp_cdata;
51    
52     $xmlcp_cdata = '';
53    
54     }
55    
56     function otd_html1_cb_xmlcp_end_headline($h_parser, $tagname) {
57    
58     global $xmlcp_cdata;
59    
60     otd_html1_headline(trim($xmlcp_cdata));
61    
62     $xmlcp_cdata = '';
63    
64     }
65    
66     /*
67     function otd_html1_cb_xmlcp_start_page($h_parser, $tagname, $attribs) {
68    
69     }
70    
71     function otd_html1_cb_xmlcp_end_page($h_parser, $tagname) {
72    
73     }
74     */
75    
76     function otd_html1_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) {
77    
78     global $xmlcp_cdata;
79    
80     $xmlcp_cdata = '';
81    
82     }
83    
84     function otd_html1_cb_xmlcp_end_paragraph($h_parser, $tagname) {
85    
86     global $xmlcp_cdata;
87    
88     otd_html1_paragraph(trim($xmlcp_cdata));
89    
90     $xmlcp_cdata = '';
91    
92     }
93    
94     //----------------------------------------------------------
95     //- Content render functions:
96    
97     function otd_html1_renderpage($keyname, $language_id = 0) {
98    
99     global $common;
100    
101     common_benchmark_addstep('otd_html1: render: start');
102    
103     $list = cms_getlist('xmlpage', $keyname);
104    
105     common_benchmark_addstep('otd_html1: render: CMS get list');
106    
107     $contentdata = cms_getcontent('xmlpage', $keyname, $language_id);
108    
109     common_benchmark_addstep('otd_html1: render: CMS get content');
110    
111     $xml = $contentdata['content'];
112    
113     otd_html1_pageheader();
114    
115     common_benchmark_addstep('otd_html1: render: header');
116    
117     if($xml) {
118    
119     $titledata = '';
120    
121     for($i = 0; $i < count($list); $i++) {
122    
123     $imgtag = '<img alt="' . $list[$i][4] . '" border="0" height="12" src="' . $common['site']['gfxurl'] . 'icons/flags/' . $list[$i][3] . '.gif" width="17" />';
124    
125     $titledata .= ($i ? '
126     ' : '') . (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '" title="' . $list[$i][4] . '">' . $imgtag . '</a>');
127    
128     }
129    
130     otd_html1_pagetitle($contentdata['description'], $titledata . '<br />');
131    
132     xmlcp_xmlpage2html($xml);
133    
134     common_benchmark_addstep('otd_html1: render: xmlpage2html');
135    
136     /*
137     otd_html1_headline('$list array, readable:');
138     otd_html1_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true))));
139    
140     otd_html1_headline('$contentdata array, readable:');
141     otd_html1_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true))));
142    
143     otd_html1_headline('$common array, readable:');
144     otd_html1_codeparagraph('$common = ' . nl2br(htmlentities(print_r($common, true))));
145    
146     otd_html1_headline('$common_sessiondata array, readable:');
147     otd_html1_codeparagraph('$common_sessiondata = ' . nl2br(htmlentities(print_r($common_sessiondata, true))));
148    
149     otd_html1_headline('Content XML:');
150     otd_html1_codeparagraph(nl2br(htmlentities($xml)));
151    
152     */
153    
154     // Only show the informations when "devstate" is set:
155     if($common['hostsetup']['devstate']) {
156    
157     otd_html1_paragraph('<small>
158     <b>Content informations:</b><br />
159     <br />
160     Description: "<b>' . $contentdata['description'] . '</b>" (Type: "xmlpage")<br />
161     Creator: "<b>' . $contentdata['creator_name'] . '</b>"<br />
162     Date, Time: "<b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>"<br />
163     Language: "<b>' . $contentdata['language_name'] . '</b>"<br />
164     XML content size: <b>' . strlen($xml) . '</b> bytes
165     </small>', 'box2');
166    
167     }
168    
169     } else {
170    
171     otd_html1_pagetitle('Bad content request');
172    
173     otd_html1_paragraph('Sorry, but the requested content is unknown.');
174    
175     }
176    
177     common_benchmark_addstep('otd_html1: render: content');
178    
179     otd_html1_pagefooter();
180    
181     }
182    
183     //----------------------------------------------------------
184     //- HTML Output functions:
185    
186     function otd_html1_authbox() {
187    
188     global $common_sessiondata;
189    
190     echo '<form action="" method="post" style="margin:0;">
191     <table cellspacing="0" cellpadding="2" class="f22">
192     <tr>
193     <th class="box2" rowspan="2"><b>User<br />login</b></th>
194     <td rowspan="2">&nbsp;</td>
195     <td>User:</td><td><input name="un" size="8" type="text" value="' . $common_sessiondata['userdata']['name'] . '" /></td>
196     <td rowspan="2">&nbsp;</td>
197     <td class="box2" rowspan="2"><input type="submit" value="OK" /></td>
198     </tr>
199     <tr>
200     <td>Pass:</td><td><input name="pw" size="8" type="password" /></td>
201     </tr>
202     </table>
203     </form>
204     ';
205    
206     }
207     function otd_html1_codeparagraph($contents) {
208    
209     echo '<p align="justify" class="hl11">
210     <code>
211     ' . $contents . '
212     </code>
213     </p>
214    
215     ';
216    
217     }
218    
219     function otd_html1_headline($caption) {
220    
221     echo '<big><u>' . $caption . '</u></big>
222    
223     ';
224    
225     }
226    
227     function otd_html1_pagefooter() {
228    
229     global $common;
230    
231     // Only show the benchmark list when "devstate" is set:
232     if($common['hostsetup']['devstate']) {
233    
234     $contents = '';
235    
236     for($i = 0; $i < count($common['benchmark']); $i++) {
237    
238     $mtimesegs = explode(' ', $common['benchmark'][$i][1]);
239     $contents .= substr('0' . ($i + 1), -2) . ': "<b>' . $common['benchmark'][$i][0] . '</b>": ';
240    
241     if($i) {
242    
243     $timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]);
244     $timediff += $mtimesegs[0] - $lastmtimesegs[0];
245    
246     $contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br />
247     ';
248    
249     } else {
250    
251     $contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br />
252     ';
253    
254     }
255    
256     $lastmtimesegs = $mtimesegs;
257    
258     }
259    
260     otd_html1_paragraph('<small>
261     <b>Partial execution times:</b><br />
262     <br />
263     ' . $contents . '</small>', 'box2');
264    
265     }
266    
267     common_benchmark_addstep('COMMON: page footer');
268    
269     $endmtimesegs = explode(' ', microtime());
270     $startmtimesegs = explode(' ', $common['benchmark'][0][1]);
271     $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);
272     $timediff += $endmtimesegs[0] - $startmtimesegs[0];
273    
274     $devstate = $common['hostsetup']['devstate'];
275    
276     echo '<table cellspacing="0" cellpadding="0" class="box1" width="100%">
277     <tr>
278     <td valign="top">
279     Page execution time: <code>' . round($timediff * 100000) / 100 . '</code> ms.<br />
280     [ ' . ($devstate ? '<a href="?devstate=0">devstate off</a>' : '<a href="?devstate=1">devstate on</a>') . ' ]
281     </td>
282     <td align="right" valign="middle"><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>
283     <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></td>
284     </tr>
285     </table>
286    
287     </td>
288    
289     </tr>
290     <tr>
291     <td></td>
292     <td width="100%"></td>
293     <td></td>
294     </tr>
295     </table>
296    
297     </body>
298    
299     </html>
300     ';
301    
302     }
303    
304     function otd_html1_pageheader() {
305    
306     global $common, $common_sessiondata;
307    
308     echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
309    
310     <html xmlns="http://www.w3.org/1999/xhtml">
311    
312     <head>
313     <title>www.netfrag.org</title>
314     <style type="text/css"><!--
315     body { margin:0; }
316     body, input, table { font: 10pt verdana, serif; }
317     input { border:1px; }
318     .bg11, .box1, .f11, .hl11 { background-color:#50f8f0; }
319     .bg12, .f12 { background-color:#40e8e0; }
320     .bg13 { background-color:#20a0c0; }
321     .bg21, .box2, .f21, .hl21 { background-color:#90fff0; }
322     .bg22, .f22 { background-color:#80f0e0; }
323     .bg23 { background-color:#40c080; }
324     .box1, .f11, .f12 { border:2px solid #20a0c0; }
325     .box2, .f21, .f22 { border:1px solid #40c080; }
326     .box1, .box2, .hl11, .hl21 { padding:4px; }
327     --></style>
328     </head>
329    
330     <body>
331    
332     ';
333    
334     }
335    
336     function otd_html1_pagetitle($title, $additionalcontents = '') {
337    
338     echo '
339     <table cellspacing="0" cellpadding="0" style="border-left:4px solid #20a0c0; border-top:4px solid #20a0c0; width:100%;">
340    
341     <tr class="bg11">
342    
343     <th colspan="2" style="padding:8px;">
344     <span style="border-bottom:2px solid black; letter-spacing:4pt; padding-bottom:4px;">
345     <font size="5">www.netfrag.org</font>
346     </span>
347     <small><br /><br />NetFrag and friends</small>
348     </th>
349    
350     <td style="border-right:4px solid #20a0c0; padding:8px;">
351     ';
352    
353     otd_html1_authbox();
354    
355     echo '</td>
356    
357     </tr>
358    
359     <tr>
360     <td class="bg11" nowrap="nowrap" width="120" style="border-bottom:4px solid #40e8e0; border-right:4px solid #20a0c0; border-top:4px solid #40e8e0; padding:8px;" valign="top">
361     ...Navigation...
362     </td>
363    
364     <td colspan="2" style="border-top:4px solid #20a0c0; padding:8px;">
365    
366     <p class="box2">
367     <big><b>&bull; ' . $title . '</b>&nbsp;</big>
368     ' . ($additionalcontents ? $additionalcontents . '
369     ' : '') . '</p>
370    
371     ';
372    
373     }
374    
375     function otd_html1_paragraph($contents, $class = '') {
376    
377     echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '>
378     ' . $contents . '
379     </p>
380    
381     ';
382    
383     }
384    
385     //------------------------------------------------------------------------------
386    
387     ?>

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