39 |
|
|
40 |
} |
} |
41 |
|
|
42 |
otd_html1_codeparagraph('<small> |
otd_html1_codeparagraph('<small><b>$' . $varname . '</b> = ' . trim($arraytext) . '</small>'); |
|
<b>$' . $varname . '</b> = ' . nl2br($arraytext) . ' |
|
|
</small>'); |
|
43 |
|
|
44 |
} |
} |
45 |
|
|
63 |
|
|
64 |
otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); |
otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); |
65 |
|
|
66 |
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('If successful, the result of the query process is shown as a table. If you want to see the complete function response then turn "Debug outputs" on.'); |
67 |
|
|
68 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
69 |
|
|
70 |
$queries = array( |
$queries = array( |
71 |
'LIST contenttypes', |
'GET COUNT FROM SOURCES', |
72 |
'GET 1, 2 FROM contenttypes', |
'GET FIELDNAMES FROM SOURCES', |
73 |
'LIST languages', |
'GET name FROM SOURCES', |
74 |
'GET 1, 2 FROM languages', |
'GET * FROM SOURCES', |
75 |
'LIST contents', |
'GET COUNT FROM contenttypes', |
76 |
'LIST contents WITH keyname=Home, language_id=1', |
'GET FIELDNAMES FROM contenttypes', |
77 |
'GET 2 FROM contents' |
'GET id, name FROM contenttypes', |
78 |
|
'GET COUNT FROM languages', |
79 |
|
'GET FIELDNAMES FROM languages', |
80 |
|
'GET id, name FROM languages', |
81 |
|
'GET * FROM languages', |
82 |
|
'GET COUNT FROM contents', |
83 |
|
'GET FIELDNAMES FROM contents', |
84 |
|
'GET type, language_id, description FROM contents', |
85 |
|
/* |
86 |
|
'GET content FROM contents WITH id 3', |
87 |
|
'GET FROM contents WITH timestamp >1000000000', |
88 |
|
'GET description, language_id FROM contents WITH keyname Home', |
89 |
|
*/ |
90 |
); |
); |
91 |
|
|
92 |
$query = (isset($_POST['q']) ? $_POST['q'] : ''); |
$query = (isset($_POST['q']) ? $_POST['q'] : ''); |
93 |
|
|
94 |
otd_html1_headline('Query command:'); |
otd_html1_headline('Query command:'); |
95 |
|
|
96 |
$options = ''; |
for($q = 0, $options = ''; $q < count($queries); $q++) |
97 |
|
$options .= '<option' . ($query == $queries[$q] ? ' selected="selected"' : '') . ' value="' . $queries[$q] . '">' . $queries[$q] . '</option> |
|
for($q = 0; $q < count($queries); $q++) { |
|
|
|
|
|
$options .= '<option value="' . $queries[$q] . '">' . $queries[$q] . '</option> |
|
98 |
'; |
'; |
99 |
|
|
|
} |
|
|
|
|
100 |
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
101 |
<select name="q" size="6"> |
<select name="q" size="1"> |
102 |
' . $options . '</select> |
' . $options . '</select> |
103 |
<input type="submit" value="OK" /> |
<input type="submit" value="OK" /> |
104 |
</form>', 'box1'); |
</form>', 'box1'); |
105 |
|
|
106 |
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
107 |
<input name="q" size="53" value="' . $query . '" /> |
<input name="q" size="50" value="' . $query . '" /> |
108 |
<input type="submit" value="OK" /> |
<input type="submit" value="OK" /> |
109 |
</form>', 'box1'); |
</form>', 'box1'); |
110 |
|
|
117 |
|
|
118 |
common_benchmark_addstep('CMS query'); |
common_benchmark_addstep('CMS query'); |
119 |
|
|
120 |
otd_html1_headline('Query execution:'); |
otd_html1_headline('Query execution response:'); |
121 |
|
|
122 |
otd_html1_paragraph('Command: "<b>' . $query . '</b>"<br /> |
otd_html1_paragraph('Command: "<b>' . $query . '</b>"', 'hl12'); |
|
Success: <b>' . ($success ? 'Yes' : 'No') . '</b>'); |
|
123 |
|
|
124 |
$resultinfo = $response[0]; |
$resultinfo = $response[0]; |
125 |
|
|
126 |
if($resultinfo['error']) { |
otd_html1_paragraph('Error: "<code>' . $resultinfo['error'] . '</code>" - "<b>' . $resultinfo['errortext'] . '</b>"', ($resultinfo['error'] ? 'hl11' : 'hl12')); |
|
|
|
|
otd_html1_headline('Query error:'); |
|
127 |
|
|
128 |
otd_html1_paragraph('Error number: "<code>' . $resultinfo['error'] . '</code>"<br /> |
// otd_html1_headline('Result:'); |
|
Error text: "<b>' . $resultinfo['errortext'] . '</b>"', 'hl12'); |
|
129 |
|
|
130 |
} else { |
if($success) { |
|
|
|
|
otd_html1_headline('Result:'); |
|
131 |
|
|
132 |
switch($resultinfo['operation']) { |
switch($resultinfo['operation']) { |
133 |
|
|
|
case 'LIST': |
|
|
|
|
|
$idlist = ''; |
|
|
|
|
|
for($r = 0; $r < count($response[1]); $r++) |
|
|
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
|
|
|
|
|
otd_html1_paragraph('List of IDs: "<code>' . $idlist . '</code>"', 'hl12'); |
|
|
|
|
|
break; |
|
|
|
|
134 |
case 'GET': |
case 'GET': |
135 |
|
|
136 |
$rows = $response[1]; |
$rows = $response[1]; |
139 |
|
|
140 |
for($x = 0; $x < count($rows[$y]); $x++) { |
for($x = 0; $x < count($rows[$y]); $x++) { |
141 |
|
|
142 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
if(strlen($rows[$y][$x]) > 97) { |
143 |
|
|
144 |
} |
$rows[$y][$x] = substr($rows[$y][$x], 0, 97) . '...'; |
145 |
|
|
146 |
if($resultinfo['source'] == 'contents') { |
} |
147 |
|
|
148 |
$rows[$y][6] = '<small><code>' . substr($rows[$y][6], 0, 124) . ' ...</code></small>'; |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
149 |
|
|
150 |
} |
} |
151 |
|
|
157 |
|
|
158 |
} |
} |
159 |
|
|
160 |
|
} else { |
161 |
|
|
162 |
|
otd_html1_paragraph('(No result returned)'); |
163 |
|
|
164 |
} |
} |
165 |
|
|
166 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |