Пример #1
0
 private function load_tweet($tweet)
 {
     $id = $tweet->id;
     $username = $tweet->user->screen_name;
     $local = $this->user;
     $uri = "http://twitter.com/{$username}/status/{$id}";
     $content = $tweet->text;
     $userid = $tweet->user->id;
     $name = $tweet->user->name;
     $ts = date('c', time($tweet->created_at));
     $user_uri = "http://twitter.com/{$username}";
     $user_foaf_uri = "http://twitter.com/{$username}#me";
     $depiction = $tweet->user->profile_image_url;
     $triples = array();
     $triples[] = array(SMOBTools::uri($uri), "a", "sioct:MicroblogPost");
     $triples[] = array("sioc:has_container", SMOBTools::uri('http://twitter.com/'));
     $triples[] = array("sioc:has_creator", SMOBTools::uri($user_uri));
     $triples[] = array("foaf:maker", SMOBTools::uri($user_foaf_uri));
     $triples[] = array("dct:created", SMOBTools::date($ts));
     $triples[] = array("dct:title", SMOBTools::literal("Update - " . $ts));
     $triples[] = array("sioc:content", SMOBTools::literal($content));
     if (strpos($content, '@' . $this->user) !== false) {
         $triples[] = array("sioc:addressed_to", SMOBTools::uri(FOAF_URI));
         $triples[] = array("sioc:addressed_to", SMOBTools::uri('http://twitter.com/' . $this->user . '#me'));
         $triples[] = array(SMOBTools::uri(FOAF_URI), 'sioc:name', SMOBTools::literal($this->user));
         $triples[] = array(SMOBTools::uri('http://twitter.com/' . $this->user . '#me'), 'sioc:name', SMOBTools::literal($this->user));
     }
     $triples[] = array(SMOBTools::uri($user_foaf_uri), "foaf:name", SMOBTools::literal($name));
     $triples[] = array("foaf:depiction", SMOBTools::uri($depiction));
     $opo_uri = $uri . '#presence';
     $triples[] = array(SMOBTools::uri($opo_uri), "a", "opo:OnlinePresence");
     $triples[] = array("opo:declaredOn", SMOBTools::uri($user_uri));
     $triples[] = array("opo:declaredBy", SMOBTools::uri($user_foaf_uri));
     $triples[] = array("opo:StartTime", SMOBTools::date($ts));
     $triples[] = array("opo:customMessage", SMOBTools::uri($uri));
     $graph = SMOB_ROOT . "data/twitter/{$id}";
     $rdf = SMOBTools::render_sparql_triples($triples);
     $query = "INSERT INTO <{$graph}> { {$rdf} }";
     $res = SMOBStore::query($query);
 }
Пример #2
0
 public function set_data($ts, $content, $reply_of, $location, $location_uri, $mappings)
 {
     $user_uri = SMOBTools::user_uri();
     $this->ts = $ts;
     $this->content = $content;
     $this->uri($ts);
     $triples[] = array(SMOBTools::uri($this->uri), "a", "sioct:MicroblogPost");
     $triples[] = array("sioc:has_container", SMOBTools::uri(SMOB_ROOT));
     $triples[] = array("sioc:has_creator", SMOBTools::uri($user_uri));
     $triples[] = array("foaf:maker", SMOBTools::uri(FOAF_URI));
     $triples[] = array("dct:created", SMOBTools::date($this->ts));
     $triples[] = array("dct:title", SMOBTools::literal("Update - " . $this->ts));
     $triples[] = array("sioc:content", SMOBTools::literal($content));
     if ($reply_of) {
         $triples[] = array("sioc:reply_of", SMOBTools::uri($reply_of));
     }
     $triples[] = array(SMOBTools::uri(SMOB_ROOT), "a", "smob:Hub");
     $opo_uri = $this->uri . '#presence';
     $triples[] = array(SMOBTools::uri($opo_uri), "a", "opo:OnlinePresence");
     $triples[] = array("opo:declaredOn", SMOBTools::uri($user_uri));
     $triples[] = array("opo:declaredBy", SMOBTools::uri(FOAF_URI));
     $triples[] = array("opo:StartTime", SMOBTools::date($this->ts));
     $triples[] = array("opo:customMessage", SMOBTools::uri($this->uri));
     if ($location_uri) {
         $triples[] = array("opo:currentLocation", SMOBTools::uri($location_uri));
         $triples[] = array(SMOBTools::uri($location_uri), "rdfs:label", SMOBTools::literal($location));
         SMOBStore::query("LOAD <{$location_uri}>");
     }
     if ($mappings) {
         $mp = explode(' ', $mappings);
         foreach ($mp as $m) {
             $mapping = explode('--', $m);
             if ($mapping[0] == 'user') {
                 $user = $mapping[1];
                 $uri = $mapping[2];
                 $triples[] = array(SMOBTools::uri($this->uri), "sioc:addressed_to", SMOBTools::uri($uri));
                 $triples[] = array(SMOBTools::uri($uri), "sioc:name", SMOBTools::literal($user));
             } elseif ($mapping[0] == 'tag' || $mapping[0] == 'location') {
                 $tag = $mapping[1];
                 $uri = $mapping[2];
                 $tagging = SMOB_ROOT . 'tagging/' . uniqid();
                 $triples[] = array(SMOBTools::uri($tagging), "a", "tags:RestrictedTagging");
                 $triples[] = array(SMOBTools::uri($tagging), "tags:taggedResource", SMOBTools::uri($this->uri));
                 $triples[] = array(SMOBTools::uri($tagging), "tags:associatedTag", SMOBTools::literal($tag));
                 $triples[] = array(SMOBTools::uri($tagging), "moat:tagMeaning", SMOBTools::uri($uri));
                 $triples[] = array(SMOBTools::uri($this->uri), "moat:taggedWith", SMOBTools::uri($uri));
             }
         }
     }
     $this->triples = $this->triples + $triples;
 }