function getLabel($x) { mysql_connect($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['password']); mysql_select_db($GLOBALS['db']); $labres = mysql_query("SELECT object FROM " . $GLOBALS['statementsTableName'] . " WHERE predicate='rdfs:label' AND subject='" . $x . "'"); if (mysql_num_rows($labres) > 0) { $labrow = mysql_fetch_array($labres); return $labrow[0]; } else { return str_replace("_", " ", urldecode(cutBaseUri($x, 'wikiBase'))); } }
function clusterConnection($first, $second) { $first = str_replace("__perc__", "%", $first); $second = str_replace("__perc__", "%", $second); $ignoredPredicates = array(); $ignoredObjects = array(); for ($t = 0; $t < 5; $t++) { if (isset($_REQUEST['ignoreObject_' . $t])) { $ignoredObjects[] = urlencode($_REQUEST['ignoreObject_' . $t]); } } for ($t = 0; $t < 5; $t++) { if (isset($_REQUEST['ignorePredicate_' . $t])) { $ignoredPredicates[] = $_REQUEST['ignorePredicate_' . $t]; } } echo '<table cellpadding="0" cellspacing="0"> <tr> <td> <table class="closeheader" style="background-color:white;"> <tr> <td>Quick Connection with Cluster Table</td><td align="right"><a href="javascript:toggle(\'clusterCon\',false);" alt="close" style="color:white;text-decoration:none;background-color:orange">x</a></td> </tr> </table> </td> </tr> <tr> <td> <table style="border: 1px solid #888;background-color:white;width:100%"> <tr> <td>'; $connectedfirst = searchClusterStart($GLOBALS['wikipediaBase'] . $first); $connectedsecond = searchClusterStart($GLOBALS['wikipediaBase'] . $second); $shortestPathFound = false; do { $popA = array_pop($connectedfirst); $popB = array_pop($connectedsecond); if ($popA == $popB) { continue; } else { $shortestPathFound = true; array_push($connectedfirst, strlen($popA) == 0 ? $GLOBALS['wikipediaBase'] . $first : $popA); array_push($connectedsecond, strlen($popB) == 0 ? $GLOBALS['wikipediaBase'] . $second : $popB); } } while ($shortestPathFound == false); echo '<table><tr>'; #print_r($ignoredObjects); #print_r($connectedsecond); for ($i = 0; $i < count($connectedfirst); $i++) { if ($i == 0) { echo '<td><a href="' . $GLOBALS['objectLinkingURL'] . cutBaseUri($connectedfirst[$i], 'wikiBase') . '">'; echo cutBaseUri($connectedfirst[$i], 'wikiBase') == $first ? '<span style="font-weight:bold">' . getLabel($connectedfirst[$i]) . '</span>' : getLabel($connectedfirst[$i]); echo '</a>'; echo '<a href="#e" onclick="ladeInfobox(\'ajax.php?f=4&actObject=' . $connectedfirst[$i] . '\',1000,\'' . str_replace('"', '', urldecode(cutBaseUri($connectedfirst[$i], 'wikiBase'))) . '\');"><img border="0" src="images/moreKnopf.png" title="show Details about this Object"></a>'; echo '</td>'; } else { $ignoretest[] = cutBaseUri(getClusterProperty($connectedfirst[$i]), 'predBase'); $ignoretest[] = cutBaseUri($connectedfirst[$i], 'wikiBase'); echo '<td><table><tr><td align="center">' . cutBaseUri(getClusterProperty($connectedfirst[$i]), 'predBase') . '</td></tr><tr><td>'; echo getClusterPropertyDirection($connectedfirst[$i], getClusterProperty($connectedfirst[$i])) == 'left' ? '<img src="images/nachlinksPfeil.png" width="90" height="10" />' : '<img src="images/nachrechtsPfeil.png" width="90" height="10" />'; echo '</td></tr></table></td>'; echo '<td><a href="' . $GLOBALS['objectLinkingURL'] . cutBaseUri($connectedfirst[$i], 'wikiBase') . '">' . getLabel($connectedfirst[$i]) . '</a>'; echo '<a href="#e" onclick="ladeInfobox(\'ajax.php?f=4&actObject=' . $connectedfirst[$i] . '\',1000,\'' . str_replace('"', '', urldecode(cutBaseUri($connectedfirst[$i], 'wikiBase'))) . '\');"><img border="0" src="images/moreKnopf.png" title="show Details about this Object"></a>'; echo '</td>'; } } for ($i = count($connectedsecond) - 1; $i >= 0; $i--) { $ignoretest[] = cutBaseUri(getClusterProperty($connectedsecond[$i]), 'predBase'); $ignoretest[] = cutBaseUri($connectedsecond[$i], 'wikiBase'); echo '<td><table><tr><td align="center">' . cutBaseUri(getClusterProperty($connectedsecond[$i]), 'predBase') . '</td></tr><tr><td>'; echo getClusterPropertyDirection($connectedsecond[$i], getClusterProperty($connectedsecond[$i])) == 'left' ? '<img src="images/nachlinksPfeil.png" width="90" height="10" />' : '<img src="images/nachrechtsPfeil.png" width="90" height="10" />'; echo '</td></tr></table></td><td><a href="' . $GLOBALS['objectLinkingURL'] . cutBaseUri($connectedsecond[$i], 'wikiBase') . '">'; echo cutBaseUri($connectedsecond[$i], 'wikiBase') == $second ? '<span style="font-weight:bold">' . getLabel($connectedsecond[$i]) . '</span>' : getLabel($connectedsecond[$i]); echo '</a>'; echo '<a href="#e" onclick="ladeInfobox(\'ajax.php?f=4&actObject=' . $connectedsecond[$i] . '\',1000,\'' . str_replace('"', '', urldecode(cutBaseUri($connectedsecond[$i], 'wikiBase'))) . '\');"><img border="0" src="images/moreKnopf.png" title="show Details about this Object"></a>'; echo '</td>'; } echo '</tr></table>'; echo ' </td> </tr>'; foreach ($ignoretest as $ignore) { if (in_array($ignore, $ignoredPredicates) || in_array($ignore, $ignoredObjects)) { echo '<tr><td><span style="color:red">Warning: The preview connection contains elements in your ignore list.</span></td></tr>'; } } echo '</table> </td> </tr>'; echo '</table>'; }
function printResults($row, &$htmlcounter, &$idcounter, $first, $second) { $k = 0; $htmlcounter++; $save = array(); echo '<tr><td style="padding-left:10px;"><span style="background-color:#e4e4e4;border:1px solid #CFCFCF;"> Result ' . $htmlcounter . ': </span></td></tr>'; echo '<tr><td style="padding-left:20px;"><table><tr>'; for ($k = 0; $k < count($row); $k++) { //Objekte if ($k % 3 == 0 || $k % 3 == 2) { if (!in_array(array(strtolower(cutBaseUri($row[$k], 'wikiBase')), $idcounter - 1), $save)) { echo '<td><table> <tr> <td>'; echo $row[$k] == $GLOBALS['wikipediaBase'] . $first || $row[$k] == $GLOBALS['wikipediaBase'] . $second ? '<span style="font-weight:bold">' : '<span>'; echo '<a href="' . $GLOBALS['objectLinkingURL'] . cutBaseUri($row[$k], 'wikiBase') . '">' . getLabel($row[$k]) . '</a></span> </td> <td> <a href="#" title="more Information" onclick="ladeInfobox(\'ajax.php?f=4&actObject=' . $row[$k] . '&actPredicate=' . ($k % 3 == 0 ? $row[$k + 1] : $row[$k - 1]) . '&k=' . $k . '\',' . $idcounter . ',\'' . str_replace('"', '', urldecode(cutBaseUri($row[$k], 'wikiBase'))) . '\');"> <img border="0" src="images/moreKnopf.png" alt="show Details about this Object"> </a><br> <a href="javascript:toggle(\'ignoreOptions\',true);" title="add to Ignore List" onclick="addNewObject(\'' . cutBaseUri($row[$k], 'wikiBase') . '\',newObjectList)"> <img border="0" src="images/ignoreKreuzProp.png" alt="ignore this Object" style="padding-left:2px;padding-top:2px;"> </a> </td> </tr> <tr> <td colspan="2"> <div id="ib_' . $idcounter . '" class="infobox"></div> </td> </tr> </table>'; echo '</td>'; //Zeilenumbruch nach dem 4. Tripel //Nach Zeilenumbruch nach links verschieben if (($k % 11 == 0 || $k % 23 == 0) && $k != 0 && isset($row[$k + 1])) { echo '</tr><tr><td colspan="10" align="center" style="padding-left:' . ($k * 10 + 10) . 'px;padding-right:30px"><img src="images/conPfeil.png" width="100%" height="26" alt="connects"></td></tr></table><table><tr><td style="padding-left:' . 8 * $k . 'px;"></td>'; } else { $save[] = array(strtolower(cutBaseUri($row[$k], 'wikiBase')), $idcounter); } //abspeichern, damit ein Objekt nicht direkt 2 mal nacheinander auftaucht $idcounter++; } } //Praedikate if ($k % 3 == 1) { $pred = getPredicate($row[$k - 1], $row[$k]); echo '<td><table><tr><td align="center">' . str_replace("_", " ", cutBaseUri($pred[0], 'predBase')); echo ' <a href="javascript:toggle(\'ignoreOptions\',true);" title="add to Ignore List" onclick="addNewObject(\'' . cutBaseUri($pred[0], 'predBase') . '\',newPredicateList)">'; echo '<img border="0" src="images/ignoreKreuzProp.png" alt="ignore this Property">'; echo '</a>'; echo '</td></tr><tr><td>'; echo $pred[1] == 'leftarrow' ? '<img src="images/nachlinksPfeil.png" width="90" height="10" alt="leftcon">' : '<img src="images/nachrechtsPfeil.png" width="90" height="10" alt="rightcon">'; echo '</td></tr></table></td>'; } } echo "</table></td></tr>"; }