61 |
|
|
62 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
63 |
|
|
64 |
otd_html1_pagetitle('Test page 1'); |
otd_html1_pagetitle('CMS test page'); |
65 |
|
|
66 |
otd_html1_paragraph('This is the first outstanding page and was created for testing.'); |
otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); |
67 |
|
|
68 |
otd_html1_headline('CMS (Content Management System) test queries:'); |
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.'); |
|
|
|
|
otd_html1_paragraph('In the following basic CMS queries are tested. Each result list is shown as a table. If you want to see explicit results turn "Debug outputs" on.'); |
|
|
|
|
|
common_benchmark_addstep('content'); |
|
69 |
|
|
70 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
71 |
|
|
72 |
$query = 'LIST languages'; |
$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 |
|
|
84 |
$response = null; |
otd_html1_headline('Query command:'); |
|
$success = cms_query($query, $response); |
|
85 |
|
|
86 |
common_benchmark_addstep('CMS query'); |
$options = ''; |
87 |
|
|
88 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
for($q = 0; $q < count($queries); $q++) { |
89 |
|
|
90 |
$idlist = ''; |
$options .= '<option value="' . $queries[$q] . '">' . $queries[$q] . '</option> |
91 |
|
'; |
92 |
|
|
93 |
for($r = 0; $r < count($response[1]); $r++) |
} |
|
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
|
|
|
|
|
otd_html1_paragraph('List of IDs: "<b>' . $idlist . '</b>"', 'hl12'); |
|
94 |
|
|
95 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
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 |
|
|
106 |
common_benchmark_addstep('content'); |
common_benchmark_addstep('content'); |
107 |
|
|
108 |
//---------------------------------------------------------- |
if($query) { |
109 |
|
|
110 |
$query = 'GET 1, 2 FROM languages'; |
$response = null; |
111 |
|
$success = cms_query($query, $response); |
112 |
|
|
113 |
$response = null; |
common_benchmark_addstep('CMS query'); |
|
$success = cms_query($query, $response); |
|
114 |
|
|
115 |
common_benchmark_addstep('CMS query'); |
otd_html1_headline('Query execution:'); |
116 |
|
|
117 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
otd_html1_paragraph('Command: "<b>' . $query . '</b>"<br /> |
118 |
|
Success: <b>' . ($success ? 'Yes' : 'No') . '</b>'); |
119 |
|
|
120 |
$rows = $response[1]; |
$resultinfo = $response[0]; |
121 |
|
|
122 |
for($y = 0; $y < count($rows); $y++) { |
if($resultinfo['error']) { |
123 |
|
|
124 |
for($x = 0; $x < count($rows[$y]); $x++) { |
otd_html1_headline('Query error:'); |
125 |
|
|
126 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
otd_html1_paragraph('Error number: "<code>' . $resultinfo['error'] . '</code>"<br /> |
127 |
|
Error text: "<b>' . $resultinfo['errortext'] . '</b>"', 'hl12'); |
128 |
|
|
129 |
} |
} else { |
130 |
|
|
131 |
} |
otd_html1_headline('Result:'); |
132 |
|
|
133 |
otd_html1_table($response[2], $rows); |
switch($resultinfo['operation']) { |
134 |
|
|
135 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
case 'LIST': |
136 |
|
|
137 |
common_benchmark_addstep('content'); |
$idlist = ''; |
138 |
|
|
139 |
//---------------------------------------------------------- |
for($r = 0; $r < count($response[1]); $r++) |
140 |
|
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
|
$query = 'LIST contents |
|
|
WITH keyname=Home, language_id=2'; |
|
141 |
|
|
142 |
$response = null; |
otd_html1_paragraph('List of IDs: "<code>' . $idlist . '</code>"', 'hl12'); |
|
$success = cms_query($query, $response); |
|
143 |
|
|
144 |
common_benchmark_addstep('CMS query'); |
break; |
145 |
|
|
146 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
case 'GET': |
147 |
|
|
148 |
$idlist = ''; |
$rows = $response[1]; |
149 |
|
|
150 |
for($r = 0; $r < count($response[1]); $r++) |
for($y = 0; $y < count($rows); $y++) { |
|
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
|
151 |
|
|
152 |
otd_html1_paragraph('List of IDs: "<b>' . $idlist . '</b>"', 'hl12'); |
for($x = 0; $x < count($rows[$y]); $x++) { |
153 |
|
|
154 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
155 |
|
|
156 |
common_benchmark_addstep('content'); |
} |
157 |
|
|
158 |
//---------------------------------------------------------- |
if($resultinfo['source'] == 'contents') { |
159 |
|
|
160 |
$query = 'GET 3 FROM contents'; |
$rows[$y][6] = '<small><code>' . substr($rows[$y][6], 0, 124) . ' ...</code></small>'; |
161 |
|
|
162 |
$response = null; |
} |
|
$success = cms_query($query, $response); |
|
163 |
|
|
164 |
common_benchmark_addstep('CMS query'); |
} |
165 |
|
|
166 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
otd_html1_table($response[2], $rows); |
167 |
|
|
168 |
$rows = $response[1]; |
break; |
169 |
|
|
170 |
for($y = 0; $y < count($rows); $y++) { |
} |
171 |
|
|
172 |
for($x = 0; $x < count($rows[$y]); $x++) { |
} |
173 |
|
|
174 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
175 |
|
|
176 |
} |
} else { |
177 |
|
|
178 |
$rows[$y][6] = '<small><code>' . substr($rows[$y][6], 0, 64) . '...</code><small>'; |
otd_html1_headline('Query execution'); |
|
} |
|
179 |
|
|
180 |
otd_html1_table($response[2], $rows); |
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 |
|
|
182 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
} |
183 |
|
|
184 |
common_benchmark_addstep('content'); |
common_benchmark_addstep('content'); |
185 |
|
|