source: Dev/branches/rest-dojo-ui/server/rdfapi/rdql/RdqlEngine.php @ 303

Last change on this file since 303 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.0 KB
Line 
1<?php
2
3// ----------------------------------------------------------------------------------
4// Class: RdqlEngine
5// ----------------------------------------------------------------------------------
6
7/**
8 * Some general methods common for RdqlMemEngine and RdqlDbEngine
9 *
10 * @version  $Id: RdqlEngine.php 268 2006-05-15 05:28:09Z tgauss $
11 * @author   Radoslaw Oldakowski <radol@gmx.de>
12 *
13 * @package rdql
14 * @access public
15 */
16
17Class RdqlEngine extends Object{
18
19       
20
21/**
22 * Prints a query result as HTML table.
23 * You can change the colors in the configuration file.
24 *
25 * @param array $queryResult [][?VARNAME] = object Node
26 * @access private
27 */
28 function writeQueryResultAsHtmlTable($queryResult) {
29          // Import Package Utility
30         include_once(RDFAPI_INCLUDE_DIR.PACKAGE_UTILITY);
31
32   if (current($queryResult[0]) == NULL) {
33      echo 'no match<br>';
34      return;
35   }
36
37   $rdfUtil = new RDFUtil();
38        echo '<table border="1" cellpadding="3" cellspacing="0"><tr><td><b>No.</b></td>';
39   foreach ($queryResult[0] as $varName => $value)
40     echo "<td align='center'><b>$varName</b></td>";
41     echo '</tr>';
42
43   foreach ($queryResult as $n => $var) {
44
45               
46     echo '<tr><td width="20" align="right">' .($n + 1) .'.</td>';
47     foreach ($var as $varName => $value) {
48       echo INDENTATION . INDENTATION . '<td bgcolor="';
49           echo $rdfutil->chooseColor($value);
50       echo '">';
51       echo '<p>';
52
53       $lang  = NULL;
54       $dtype = NULL;
55       if (is_a($value, 'Literal')) {
56           if ($value->getLanguage() != NULL)
57               $lang = ' <b>(xml:lang="' . $value->getLanguage() . '") </b> ';
58                   if ($value->getDatatype() != NULL)
59                          $dtype = ' <b>(rdf:datatype="' . $value->getDatatype() . '") </b> ';
60       }
61           echo  $rdfutil->getNodeTypeName($value) .$value->getLabel() . $lang . $dtype .'</p>';
62     }
63     echo '</tr>';
64   }
65   echo '</table>';
66 }
67 
68} // end: Class RdqlEngine
69
70?>
Note: See TracBrowser for help on using the repository browser.