コード例 #1
0
ファイル: view.php プロジェクト: rowanthorpe/myprofile
 if (strlen($_REQUEST['webid']) > 50) {
     $ret .= substr(urldecode($_REQUEST['webid']), 0, 47) . '...';
 } else {
     $ret .= urldecode($_REQUEST['webid']);
 }
 $ret .= "</a></h3><p>(view  <a href=\"view.php?html=0&webid=" . urlencode($_REQUEST['webid']) . "\">RDF</a> or \n";
 $ret .= "</a></h3><a href=\"view.php?html=1&webid=" . urlencode($_REQUEST['webid']) . "\">normal</a>?)</p><br/>\n";
 // graph
 $person = new MyProfile(urldecode($_REQUEST['webid']), BASE_URI, SPARQL_ENDPOINT);
 $person->load(true);
 $graph = $person->get_graph();
 $profile = $person->get_profile();
 // sameAs is disabled until further notice
 //$profile->loadSameAs();
 // check if the user has subscribed to local messages
 $is_subscribed = strlen($person->get_hash()) > 0 ? true : false;
 $ret .= "<table><tr>\n";
 // add or remove friends if we have them in our list
 if (isset($_SESSION['webid']) && webid_is_local($_SESSION['webid'])) {
     if ($_SESSION['myprofile']->is_friend($_REQUEST['webid'])) {
         // remove friend
         $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
         $ret .= "<input type=\"hidden\" name=\"action\" value=\"delfriend\">\n";
         $ret .= "<input type=\"hidden\" name=\"webid\" value=\"" . $_REQUEST['webid'] . "\">\n";
         $ret .= "<input src=\"img/actions/remove.png\" type=\"image\" title=\"Remove friend\" name=\"submit\" value=\" Remove \">\n";
         $ret .= "</form></td>\n";
     } else {
         // add friend
         $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
         $ret .= "<input type=\"hidden\" name=\"action\" value=\"addfriend\">\n";
         $ret .= "<input type=\"hidden\" name=\"webid\" value=\"" . $_REQUEST['webid'] . "\">\n";
コード例 #2
0
ファイル: functions.php プロジェクト: rowanthorpe/myprofile
function viewShortInfo($webid, $me, $base_uri, $endpoint)
{
    // fetch info for webid
    $ret = '';
    $person = new MyProfile($webid, $base_uri, $endpoint);
    $person->load();
    $profile = $person->get_profile();
    // find if he has me in his list of foaf:knows!
    $has_me = false;
    if (in_array($me, $profile->all('foaf:knows'))) {
        $has_me = true;
    }
    // check if the user has subscribed to local messages
    $is_subscribed = strlen($person->get_hash()) > 0 ? true : false;
    // start populating array
    $friend = array('webid' => (string) $webid, 'img' => (string) $person->get_picture(), 'name' => (string) $profile->get("foaf:name"), 'nick' => (string) $profile->get("foaf:nick"), 'email' => (string) $profile->get("foaf:mbox"), 'blog' => (string) $profile->get("foaf:weblog"), 'pingback' => (string) $profile->get("http://purl.org/net/pingback/to"), 'hash' => $person->get_hash(), 'hasme' => $has_me);
    if (isset($new)) {
        $friend['new'] = $new;
    }
    $ret .= "<table>\n";
    $ret .= "<tr bgcolor=\"\"><td>\n";
    $ret .= "<table><tr>\n";
    $ret .= "<td width=\"70\" style=\"vertical-align: top; padding: 10px;\">\n";
    $ret .= "<div align=\"left\"><a href=\"view.php?webid=" . urlencode($friend['webid']) . "\" target=\"_blank\">";
    $ret .= "<img title=\"" . $friend['name'] . "\" alt=\"" . $friend['name'] . ".\" width=\"64\" src=\"" . $friend['img'] . "\" />";
    $ret .= "</a></div>\n";
    $ret .= "</td>\n";
    $ret .= "<td><table>\n";
    if ($friend['name'] != null) {
        $ret .= "<tr><td><strong>" . $friend['name'] . "</strong>\n";
    } else {
        $ret .= "<tr><td><strong>Anonymous</strong>\n";
    }
    if ($friend['nick'] != null) {
        $ret .= "''" . $friend['nick'] . "''";
    }
    $ret .= "</td></tr>\n";
    if ($friend['hasme'] == true) {
        $ret .= "<tr><td><div style=\"color:#60be60;\">Has you as friend.</div></td></tr>\n";
    }
    //$ret .= "<tr><td>&nbsp;</td></tr>\n";
    if ($friend['email'] != null) {
        $ret .= "<tr><td>Email: <a href=\"" . $friend['email'] . "\">" . clean_mail($friend['email']) . "</a></td></tr>\n";
    }
    if ($friend['blog'] != null) {
        $ret .= "<tr><td>Blog:<a href=\"" . $friend['blog'] . "\">" . $friend['blog'] . "</a></td></tr>\n";
    }
    $ret .= "<tr><td>WebID: <a href=\"view.php?webid=" . urlencode($friend['webid']) . "\">" . $friend['webid'] . "</a></td></tr>\n";
    $ret .= "</table>\n";
    $ret .= "<br/><table>\n";
    $ret .= "<tr>\n";
    // add or remove friends if we have them in our list
    if (isset($_SESSION['webid']) && webid_is_local($_SESSION['webid'])) {
        if ($_SESSION['myprofile']->is_friend($webid)) {
            // remove friend
            $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
            $ret .= "<input type=\"hidden\" name=\"action\" value=\"delfriend\">\n";
            $ret .= "<input type=\"hidden\" name=\"uri\" value=\"" . $friend['webid'] . "\">\n";
            $ret .= "<input src=\"img/actions/remove.png\" type=\"image\" title=\"Remove friend\" name=\"submit\" value=\" Remove \">\n";
            $ret .= "</form></td>\n";
        } else {
            // add friend
            $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"POST\">\n";
            $ret .= "<input type=\"hidden\" name=\"action\" value=\"addfriend\">\n";
            $ret .= "<input type=\"hidden\" name=\"uri\" value=\"" . $friend['webid'] . "\">\n";
            $ret .= "<input src=\"img/actions/add.png\" type=\"image\" title=\"Add friend\" name=\"submit\" value=\" Add \">\n";
            $ret .= "</form></td>\n";
        }
    }
    // send messages using the pingback protocol
    if ($friend['pingback'] != null) {
        $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"messages.php\" method=\"POST\">\n";
        $ret .= "<input type=\"hidden\" name=\"new\" value=\"true\">\n";
        $ret .= "<input type=\"hidden\" name=\"to\" value=\"" . $friend['webid'] . "\">\n";
        $ret .= "<input src=\"img/actions/message.png\" type=\"image\" title=\"Send a message\" name=\"submit\" value=\" Message \" onclick=\"this.form.target='_blank';return true;\">\n";
        $ret .= "</form></td>\n";
    }
    // more functions if the user has previously subscribed to the local services
    if ($is_subscribed) {
        // Post on the user's wall
        $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"wall.php\" method=\"POST\">\n";
        $ret .= "<input type=\"hidden\" name=\"user\" value=\"" . $friend['hash'] . "\">\n";
        $ret .= "<input src=\"img/actions/wall.png\" type=\"image\" title=\"View posts\" name=\"submit\" value=\" Wall \" onclick=\"this.form.target='_blank';return true;\">\n";
        $ret .= "</form></td>\n";
    }
    $ret .= "<td style=\"padding-right: 10px; float: left;\"><form action=\"friends.php\" method=\"GET\">\n";
    $ret .= "<input type=\"hidden\" name=\"webid\" value=\"" . $friend['webid'] . "\">\n";
    $ret .= "<input type=\"hidden\" name=\"me\" value=\"" . $me . "\">\n";
    $ret .= "<input src=\"img/actions/friends.png\" type=\"image\" title=\"View friends\" name=\"submit\" value=\" Friends \">\n";
    $ret .= "</form></td>\n";
    $ret .= "</tr></table></p>\n";
    $ret .= "</td>\n";
    $ret .= "</tr></table>\n";
    $ret .= "</td></tr>\n";
    $ret .= "</table>\n";
    return $ret;
}