/[cvs]/nfo/site/htdocs/pages/otd_html1/userinfo.php
ViewVC logotype

Annotation of /nfo/site/htdocs/pages/otd_html1/userinfo.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Mon Sep 6 03:03:28 2004 UTC (20 years ago) by rabit
Branch: MAIN
Changes since 1.3: +70 -62 lines
+ Query testing input field; + Option list of pre-defined queries; + Dispatching of viewing format by query operation (LIST, GET, ...); U page title; U content.

1 rabit 1.1 <?php $ID = substr(
2     /*------------------------------------------------------------------------------
3     --- www.netfrag.org
4     --- HTML1: user info page.
5     --------------------------------------------------------------------------------
6     --- rabit, 02:29 05.09.2004
7     ------------------------------------------------------------------------------*/
8 rabit 1.4 '$Id: userinfo.php,v 1.3 2004/09/06 01:05:41 rabit Exp $'
9 rabit 1.1 //------------------------------------------------------------------------------
10     , 5, -2);
11     //------------------------------------------------------------------------------
12    
13     include('../../inc/common/common.php.inc');
14    
15     include('../../inc/otdef/otd_html1/otd_html1.php.inc');
16    
17     common_benchmark_addstep('OTD_HTML1 included');
18    
19 rabit 1.2 //------------------------------------------------------------------------------
20    
21     function variablebox($varname) {
22    
23     global $$varname;
24    
25     $arraytext = htmlentities(print_r($$varname, true));
26     $arraytext = str_replace(' ', '&nbsp;', $arraytext);
27     $arraytext = str_replace("Array\n", 'array&nbsp;', $arraytext);
28     $arraytext = str_replace('&nbsp;)', ')', $arraytext);
29     $arraytext = str_replace("\n\n", "\n", $arraytext);
30    
31     $len = strlen($arraytext);
32     $oldlen = 0;
33    
34     while($len != $oldlen) {
35    
36     $oldlen = strlen($arraytext);
37     $arraytext = str_replace("array&nbsp;&nbsp;", 'array&nbsp;', $arraytext);
38     $len = strlen($arraytext);
39    
40     }
41    
42     otd_html1_codeparagraph('<small>
43     <b>$' . $varname . '</b> = ' . nl2br($arraytext) . '
44     </small>');
45    
46     }
47    
48     common_benchmark_addstep('functions');
49 rabit 1.1
50     //------------------------------------------------------------------------------
51    
52 rabit 1.2 common_benchmark_addstep('start');
53    
54 rabit 1.1 otd_html1_pagehead();
55    
56     common_benchmark_addstep('head');
57    
58     otd_html1_pageheader();
59    
60     common_benchmark_addstep('header');
61    
62     //----------------------------------------------------------
63    
64 rabit 1.3 otd_html1_pagetitle('CMS test page');
65 rabit 1.2
66 rabit 1.4 otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.');
67 rabit 1.2
68 rabit 1.4 otd_html1_paragraph('The result of each different query operation is shown in its own specific format. If you want to see the complete function response then turn "Debug outputs" on.');
69 rabit 1.2
70     //----------------------------------------------------------
71    
72 rabit 1.4 $queries = array(
73     'LIST contenttypes',
74     'GET 1, 2 FROM contenttypes',
75     'LIST languages',
76     'GET 1, 2 FROM languages',
77     'LIST contents',
78     'LIST contents WITH keyname=Home, language_id=1',
79     'GET 2 FROM contents'
80     );
81    
82     $query = (isset($_POST['q']) ? $_POST['q'] : '');
83 rabit 1.2
84 rabit 1.4 otd_html1_headline('Query command:');
85 rabit 1.2
86 rabit 1.4 $options = '';
87 rabit 1.2
88 rabit 1.4 for($q = 0; $q < count($queries); $q++) {
89 rabit 1.2
90 rabit 1.4 $options .= '<option value="' . $queries[$q] . '">' . $queries[$q] . '</option>
91     ';
92 rabit 1.2
93 rabit 1.4 }
94 rabit 1.2
95 rabit 1.4 otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;">
96     <select name="q" size="6">
97     ' . $options . '</select>
98     <input type="submit" value="OK" />
99     </form>', 'box1');
100    
101     otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;">
102     <input name="q" size="53" value="' . $query . '" />
103     <input type="submit" value="OK" />
104     </form>', 'box1');
105 rabit 1.2
106 rabit 1.4 common_benchmark_addstep('content');
107 rabit 1.2
108 rabit 1.4 if($query) {
109 rabit 1.2
110 rabit 1.4 $response = null;
111     $success = cms_query($query, $response);
112 rabit 1.2
113 rabit 1.4 common_benchmark_addstep('CMS query');
114 rabit 1.1
115 rabit 1.4 otd_html1_headline('Query execution:');
116 rabit 1.1
117 rabit 1.4 otd_html1_paragraph('Command: "<b>' . $query . '</b>"<br />
118     Success: <b>' . ($success ? 'Yes' : 'No') . '</b>');
119 rabit 1.1
120 rabit 1.4 $resultinfo = $response[0];
121 rabit 1.1
122 rabit 1.4 if($resultinfo['error']) {
123 rabit 1.2
124 rabit 1.4 otd_html1_headline('Query error:');
125 rabit 1.2
126 rabit 1.4 otd_html1_paragraph('Error number: "<code>' . $resultinfo['error'] . '</code>"<br />
127     Error text: "<b>' . $resultinfo['errortext'] . '</b>"', 'hl12');
128 rabit 1.2
129 rabit 1.4 } else {
130 rabit 1.2
131 rabit 1.4 otd_html1_headline('Result:');
132 rabit 1.1
133 rabit 1.4 switch($resultinfo['operation']) {
134 rabit 1.1
135 rabit 1.4 case 'LIST':
136 rabit 1.2
137 rabit 1.4 $idlist = '';
138 rabit 1.2
139 rabit 1.4 for($r = 0; $r < count($response[1]); $r++)
140     $idlist .= ($r ? ', ' : '') . $response[1][$r][0];
141 rabit 1.2
142 rabit 1.4 otd_html1_paragraph('List of IDs: "<code>' . $idlist . '</code>"', 'hl12');
143 rabit 1.1
144 rabit 1.4 break;
145 rabit 1.2
146 rabit 1.4 case 'GET':
147 rabit 1.2
148 rabit 1.4 $rows = $response[1];
149 rabit 1.2
150 rabit 1.4 for($y = 0; $y < count($rows); $y++) {
151 rabit 1.2
152 rabit 1.4 for($x = 0; $x < count($rows[$y]); $x++) {
153 rabit 1.2
154 rabit 1.4 $rows[$y][$x] = htmlentities($rows[$y][$x]);
155 rabit 1.2
156 rabit 1.4 }
157 rabit 1.2
158 rabit 1.4 if($resultinfo['source'] == 'contents') {
159 rabit 1.2
160 rabit 1.4 $rows[$y][6] = '<small><code>' . substr($rows[$y][6], 0, 124) . ' ...</code></small>';
161 rabit 1.1
162 rabit 1.4 }
163 rabit 1.2
164 rabit 1.4 }
165 rabit 1.2
166 rabit 1.4 otd_html1_table($response[2], $rows);
167 rabit 1.2
168 rabit 1.4 break;
169 rabit 1.2
170 rabit 1.4 }
171 rabit 1.2
172 rabit 1.4 }
173 rabit 1.2
174 rabit 1.4 if($common_sessiondata['user_prefs']['debug']) variablebox('response');
175 rabit 1.2
176 rabit 1.4 } else {
177 rabit 1.2
178 rabit 1.4 otd_html1_headline('Query execution');
179 rabit 1.2
180 rabit 1.4 otd_html1_paragraph('Select a pre-defined query string from the list or enter a new one into the text input field. Press the "<b>GO</b>" button in both cases to execute the query.');
181 rabit 1.2
182     }
183    
184     common_benchmark_addstep('content');
185    
186     //----------------------------------------------------------
187    
188 rabit 1.1 $extrapageinfocontents = 'Page created by <b>rabit</b> on <b>2004/09/05, 02:29</b>.';
189    
190     otd_html1_pagefooter($extrapageinfocontents);
191    
192     common_benchmark_addstep('footer');
193    
194     otd_html1_pagefoot();
195    
196     //------------------------------------------------------------------------------
197    
198     ?>

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