| 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 |
|
|
| 61 |
|
|
| 62 |
otd_html1_pagetitle('CMS test page'); |
otd_html1_pagetitle('CMS test page'); |
| 63 |
|
|
| 64 |
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.'); |
| 65 |
|
|
| 66 |
otd_html1_headline('CMS (Content Management System) test queries:'); |
//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.'); |
|
|
|
|
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'); |
|
| 67 |
|
|
| 68 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 69 |
|
|
| 70 |
$query = 'LIST languages'; |
$queries = array( |
| 71 |
|
'GET COUNT FROM SOURCES', |
| 72 |
$response = null; |
'GET FIELDNAMES FROM SOURCES', |
| 73 |
$success = cms_query($query, $response); |
'GET name FROM SOURCES', |
| 74 |
|
'GET * FROM SOURCES', |
| 75 |
common_benchmark_addstep('CMS query'); |
'GET COUNT FROM contenttypes', |
| 76 |
|
'GET FIELDNAMES FROM contenttypes', |
| 77 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
'GET id, name FROM contenttypes', |
| 78 |
|
'GET COUNT FROM languages', |
| 79 |
$idlist = ''; |
'GET FIELDNAMES FROM languages', |
| 80 |
|
'GET id, name FROM languages', |
| 81 |
for($r = 0; $r < count($response[1]); $r++) |
'GET * FROM languages', |
| 82 |
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
'GET COUNT FROM contents', |
| 83 |
|
'GET FIELDNAMES FROM contents', |
| 84 |
otd_html1_paragraph('List of IDs: "<b>' . $idlist . '</b>"', 'hl12'); |
'GET type, language_id, description FROM contents', |
| 85 |
|
'GET id, keyname, description FROM contents WITH type xmlpage', |
| 86 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
'GET id, description FROM contents WITH language_id 2', |
| 87 |
|
'GET id, description FROM contents WITH type xmlpage ORDERBY id COUNT 5', |
| 88 |
|
/* |
| 89 |
|
'GET content FROM contents WITH id 3', |
| 90 |
|
'GET FROM contents WITH timestamp >1000000000', |
| 91 |
|
'GET description, language_id FROM contents WITH keyname Home', |
| 92 |
|
*/ |
| 93 |
|
); |
| 94 |
|
|
| 95 |
|
$query = (isset($_POST['q']) ? $_POST['q'] : ''); |
| 96 |
|
|
| 97 |
|
otd_html1_headline('Query command:'); |
| 98 |
|
|
| 99 |
|
for($q = 0, $options = ''; $q < count($queries); $q++) |
| 100 |
|
$options .= '<option' . ($query == $queries[$q] ? ' selected="selected"' : '') . ' value="' . $queries[$q] . '">' . $queries[$q] . '</option> |
| 101 |
|
'; |
| 102 |
|
|
| 103 |
|
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
| 104 |
|
<select name="q" size="1"> |
| 105 |
|
' . $options . '</select> |
| 106 |
|
<input type="submit" value="OK" /> |
| 107 |
|
</form>', 'box1'); |
| 108 |
|
|
| 109 |
|
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
| 110 |
|
<input name="q" size="76" value="' . $query . '" /> |
| 111 |
|
<input type="submit" value="OK" /> |
| 112 |
|
</form>', 'box1'); |
| 113 |
|
|
| 114 |
common_benchmark_addstep('content'); |
common_benchmark_addstep('content'); |
| 115 |
|
|
| 116 |
//---------------------------------------------------------- |
if($query) { |
| 117 |
|
|
| 118 |
$query = 'GET 1, 2 FROM languages'; |
$response = null; |
| 119 |
|
$success = cms_query($query, $response); |
| 120 |
|
|
| 121 |
$response = null; |
common_benchmark_addstep('CMS query'); |
|
$success = cms_query($query, $response); |
|
| 122 |
|
|
| 123 |
common_benchmark_addstep('CMS query'); |
otd_html1_headline('Query execution response:'); |
| 124 |
|
|
| 125 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
otd_html1_paragraph('Command: "<b>' . $query . '</b>"', 'hl12'); |
| 126 |
|
|
| 127 |
$rows = $response[1]; |
$resultinfo = $response[0]; |
| 128 |
|
|
| 129 |
for($y = 0; $y < count($rows); $y++) { |
otd_html1_paragraph('Error: "<code>' . $resultinfo['error'] . '</code>" - "<b>' . $resultinfo['errortext'] . '</b>"', ($resultinfo['error'] ? 'hl11' : 'hl12')); |
| 130 |
|
|
| 131 |
for($x = 0; $x < count($rows[$y]); $x++) { |
// otd_html1_headline('Result:'); |
| 132 |
|
|
| 133 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
if($success) { |
| 134 |
|
|
| 135 |
} |
switch($resultinfo['operation']) { |
| 136 |
|
|
| 137 |
} |
case 'GET': |
| 138 |
|
|
| 139 |
otd_html1_table($response[2], $rows); |
$rows = $response[1]; |
| 140 |
|
|
| 141 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
for($y = 0; $y < count($rows); $y++) { |
| 142 |
|
|
| 143 |
common_benchmark_addstep('content'); |
for($x = 0; $x < count($rows[$y]); $x++) { |
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
$query = 'LIST contents |
|
|
WITH keyname=Home, language_id=2'; |
|
|
|
|
|
$response = null; |
|
|
$success = cms_query($query, $response); |
|
|
|
|
|
common_benchmark_addstep('CMS query'); |
|
| 144 |
|
|
| 145 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
if(strlen($rows[$y][$x]) > 97) { |
| 146 |
|
|
| 147 |
$idlist = ''; |
$rows[$y][$x] = substr($rows[$y][$x], 0, 97) . '...'; |
| 148 |
|
|
| 149 |
for($r = 0; $r < count($response[1]); $r++) |
} |
|
$idlist .= ($r ? ', ' : '') . $response[1][$r][0]; |
|
| 150 |
|
|
| 151 |
otd_html1_paragraph('List of IDs: "<b>' . $idlist . '</b>"', 'hl12'); |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
| 152 |
|
|
| 153 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
} |
| 154 |
|
|
| 155 |
common_benchmark_addstep('content'); |
} |
| 156 |
|
|
| 157 |
//---------------------------------------------------------- |
otd_html1_table($response[2], $rows); |
| 158 |
|
|
| 159 |
$query = 'GET 3 FROM contents'; |
break; |
| 160 |
|
|
| 161 |
$response = null; |
} |
|
$success = cms_query($query, $response); |
|
| 162 |
|
|
| 163 |
common_benchmark_addstep('CMS query'); |
} else { |
| 164 |
|
|
| 165 |
otd_html1_paragraph('CMS query "<b>' . $query . '</b>" returned "<code>' . $success . '</code>":'); |
otd_html1_paragraph('(No result returned)'); |
| 166 |
|
|
| 167 |
$rows = $response[1]; |
} |
| 168 |
|
|
| 169 |
for($y = 0; $y < count($rows); $y++) { |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
| 170 |
|
|
| 171 |
for($x = 0; $x < count($rows[$y]); $x++) { |
} else { |
| 172 |
|
|
| 173 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
otd_html1_headline('Query execution'); |
| 174 |
|
|
| 175 |
} |
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.'); |
| 176 |
|
|
|
$rows[$y][6] = '<small><code>' . substr($rows[$y][6], 0, 64) . '...</code><small>'; |
|
| 177 |
} |
} |
| 178 |
|
|
|
otd_html1_table($response[2], $rows); |
|
|
|
|
|
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
|
|
|
|
| 179 |
common_benchmark_addstep('content'); |
common_benchmark_addstep('content'); |
| 180 |
|
|
| 181 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |