function sparql_lookup($string, $base_uri, $endpoint) { $ret = ''; $ret .= "<table>\n"; // check if we have a WebID uri in the search input if (strpos(urldecode($string), '#') === false) { // search the local cache for a match $sparql = sparql_connect($endpoint); // Try to match against the name, nickname or webid. $query = 'SELECT DISTINCT ?webid WHERE { ?webid foaf:name ?name . ?webid foaf:nick ?nick . FILTER (regex(?name, "' . $string . '", "i") || regex(?nick, "' . $string . '", "i") || regex(?webid, "' . $string . '", "i")) MINUS { ?webid a foaf:Person . FILTER (regex(?webid, "nodeID", "i")) . FILTER (regex(?webid, "_:", "i")) } }'; $result = $sparql->query($query); if (!$result) { $ret .= error(sparql_errno() . ": " . sparql_error()); } while ($row = $result->fetch_array($result)) { $ret .= viewShortInfo($row['webid'], $_SESSION['webid'], $base_uri, $endpoint); } } else { // use the WebID source $ret .= viewShortInfo($string, $_SESSION['webid'], $base_uri, $endpoint); } $ret .= "</table>\n"; return $ret; }
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is furnished * to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ include_once 'include.php'; $ret = ""; if (isset($_SESSION['webid'])) { $me = $_SESSION['webid']; } else { if (isset($_REQUEST['me'])) { $me = urldecode($_REQUEST['me']); } } if (isset($_REQUEST['webid'])) { $webid = urldecode($_REQUEST['webid']); $ret .= viewShortInfo($webid, $me, $base_uri, SPARQL_ENDPOINT); } else { $ret .= "You need to specify a person."; } echo $ret; ?>