| 16 |
|
|
| 17 |
common_benchmark_addstep('OTD_HTML1 included'); |
common_benchmark_addstep('OTD_HTML1 included'); |
| 18 |
|
|
| 19 |
common_benchmark_addstep('start'); |
//------------------------------------------------------------------------------ |
| 20 |
|
|
| 21 |
|
function variablebox($varname) { |
| 22 |
|
|
| 23 |
|
global $$varname; |
| 24 |
|
|
| 25 |
|
$arraytext = htmlentities(print_r($$varname, true)); |
| 26 |
|
$arraytext = str_replace(' ', ' ', $arraytext); |
| 27 |
|
$arraytext = str_replace("Array\n", 'array ', $arraytext); |
| 28 |
|
$arraytext = str_replace(' )', ')', $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 ", 'array ', $arraytext); |
| 38 |
|
$len = strlen($arraytext); |
| 39 |
|
|
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
otd_html1_codeparagraph('<small><b>$' . $varname . '</b> = ' . trim($arraytext) . '</small>'); |
| 43 |
|
|
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
common_benchmark_addstep('functions'); |
| 47 |
|
|
| 48 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 49 |
|
|
| 50 |
|
common_benchmark_addstep('start'); |
| 51 |
|
|
| 52 |
otd_html1_pagehead(); |
otd_html1_pagehead(); |
| 53 |
|
|
| 54 |
common_benchmark_addstep('head'); |
common_benchmark_addstep('head'); |
| 59 |
|
|
| 60 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 61 |
|
|
| 62 |
otd_html1_pagetitle('User info'); |
otd_html1_pagetitle('CMS test page'); |
| 63 |
|
|
| 64 |
otd_html1_paragraph('This is an overview of your preferences and informations related to you and your visit. You may also change global settings here.'); |
otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); |
| 65 |
|
|
| 66 |
otd_html1_paragraph('Also it is the first outstanding page and was created for testing yet.'); |
//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 |
// Only show debug outputs when set as preference: |
//---------------------------------------------------------- |
|
if($common_sessiondata['user_prefs']['debug']) { |
|
| 69 |
|
|
| 70 |
otd_html1_headline('User preferences array:'); |
$queries = array( |
| 71 |
otd_html1_codeparagraph('$common_sessiondata[user_prefs] = ' . nl2br(htmlentities(print_r($common_sessiondata['user_prefs'], true)))); |
'GET COUNT FROM SOURCES', |
| 72 |
|
'GET FIELDNAMES FROM SOURCES', |
| 73 |
|
'GET name FROM SOURCES', |
| 74 |
|
'GET * FROM SOURCES', |
| 75 |
|
'GET COUNT FROM contenttypes', |
| 76 |
|
'GET FIELDNAMES FROM contenttypes', |
| 77 |
|
'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 |
|
'GET id, keyname, description FROM contents WITH type xmlpage', |
| 86 |
|
'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'); |
| 115 |
|
|
| 116 |
//---------------------------------------------------------- |
if($query) { |
| 117 |
|
|
| 118 |
|
$response = null; |
| 119 |
|
$success = cms_query($query, $response); |
| 120 |
|
|
| 121 |
|
common_benchmark_addstep('CMS query'); |
| 122 |
|
|
| 123 |
|
otd_html1_headline('Query execution response:'); |
| 124 |
|
|
| 125 |
|
otd_html1_paragraph('Command: "<b>' . $query . '</b>"', 'hl12'); |
| 126 |
|
|
| 127 |
|
$resultinfo = $response[0]; |
| 128 |
|
|
| 129 |
|
otd_html1_paragraph('Error: "<code>' . $resultinfo['error'] . '</code>" - "<b>' . $resultinfo['errortext'] . '</b>"', ($resultinfo['error'] ? 'hl11' : 'hl12')); |
| 130 |
|
|
| 131 |
|
// otd_html1_headline('Result:'); |
| 132 |
|
|
| 133 |
|
if($success) { |
| 134 |
|
|
| 135 |
|
switch($resultinfo['operation']) { |
| 136 |
|
|
| 137 |
|
case 'GET': |
| 138 |
|
|
| 139 |
|
$rows = $response[1]; |
| 140 |
|
|
| 141 |
|
for($y = 0; $y < count($rows); $y++) { |
| 142 |
|
|
| 143 |
|
for($x = 0; $x < count($rows[$y]); $x++) { |
| 144 |
|
|
| 145 |
|
if(strlen($rows[$y][$x]) > 97) { |
| 146 |
|
|
| 147 |
|
$rows[$y][$x] = substr($rows[$y][$x], 0, 97) . '...'; |
| 148 |
|
|
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
| 152 |
|
|
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
otd_html1_table($response[2], $rows); |
| 158 |
|
|
| 159 |
|
break; |
| 160 |
|
|
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
} else { |
| 164 |
|
|
| 165 |
|
otd_html1_paragraph('(No result returned)'); |
| 166 |
|
|
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
| 170 |
|
|
| 171 |
|
} else { |
| 172 |
|
|
| 173 |
|
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 |
|
|
| 177 |
|
} |
| 178 |
|
|
| 179 |
common_benchmark_addstep('content'); |
common_benchmark_addstep('content'); |
| 180 |
|
|
| 181 |
|
//---------------------------------------------------------- |
| 182 |
|
|
| 183 |
$extrapageinfocontents = 'Page created by <b>rabit</b> on <b>2004/09/05, 02:29</b>.'; |
$extrapageinfocontents = 'Page created by <b>rabit</b> on <b>2004/09/05, 02:29</b>.'; |
| 184 |
|
|
| 185 |
otd_html1_pagefooter($extrapageinfocontents); |
otd_html1_pagefooter($extrapageinfocontents); |