Changeset 715544
- Timestamp:
- 05/20/2013 10:36:19 AM (13 years ago)
- Location:
- wp-linked-data/trunk
- Files:
-
- 2 edited
-
rdf/RdfBuilder.php (modified) (6 diffs)
-
wp-linked-data.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-linked-data/trunk/rdf/RdfBuilder.php
r705406 r715544 10 10 public function buildGraph ($queriedObject, $wpQuery) { 11 11 $graph = new \EasyRdf_Graph(); 12 if (!$queriedObject) { 13 return $this->buildGraphForBlog ($graph, $wpQuery); 14 } 12 15 if ($queriedObject) { 13 16 if ($queriedObject instanceof \WP_User) { … … 36 39 37 40 $post_resource->set ('dc:title', $post->post_title); 38 $post_resource->set (' dc:content', $post->post_content);41 $post_resource->set ('sioc:content', strip_tags($post->post_content)); 39 42 $post_resource->set ('dc:modified', \EasyRdf_Literal_Date::parse($post->post_modified)); 40 43 $post_resource->set ('dc:created', \EasyRdf_Literal_Date::parse($post->post_date)); 41 44 42 45 $author = get_userdata ($post->post_author); 43 $author_uri = $this->getAuthorUri ($author); 44 $author_resource = $graph->resource ($author_uri, 'foaf:Person'); 45 $author_resource->set ('foaf:name', $author->display_name); 46 $post_resource->set ('dc:creator', $author_resource); 46 $accountUri = $this->getAccountUri ($author); 47 $accountResource = $graph->resource ($accountUri, 'sioc:UserAccount'); 48 $accountResource->set ('sioc:name', $author->display_name); 49 $post_resource->set ('sioc:has_creator', $accountResource); 50 51 $blogUri = $this->getBlogUri (); 52 $blogResource = $graph->resource ($blogUri, 'sioct:Weblog'); 53 $post_resource->set ('sioc:has_container', $blogResource); 47 54 48 55 return $graph; … … 54 61 55 62 private function getAuthorUri ($author) { 56 return untrailingslashit (get_author_posts_url ($author->ID)) . '#me'; 63 return $this->getAuthorDocumentUri ($author) . '#me'; 64 } 65 66 private function getAccountUri ($author) { 67 return $this->getAuthorDocumentUri ($author) . '#account'; 68 } 69 70 private function getAuthorDocumentUri ($author) { 71 return untrailingslashit (get_author_posts_url ($author->ID)); 57 72 } 58 73 … … 66 81 private function buildGraphForUser ($graph, $user, $wpQuery) { 67 82 $author_uri = $this->getAuthorUri ($user); 83 $account_uri = $this->getAccountUri ($user); 68 84 $author_resource = $graph->resource ($author_uri, 'foaf:Person'); 85 $account_resource = $graph->resource ($account_uri, 'sioc:UserAccount'); 86 69 87 $author_resource->set ('foaf:name', $user->display_name ?: null); 70 88 $author_resource->set ('foaf:givenName', $user->user_firstname ?: null); … … 72 90 $author_resource->set ('foaf:nick', $user->nickname ?: null); 73 91 $author_resource->set ('bio:olb', $user->user_description ?: null); 92 $author_resource->set ('foaf:account', $account_resource); 74 93 94 $account_resource->set ('sioc:name', $user->display_name ?: null); 95 $account_resource->set ('sioc:account_of', $author_resource); 96 97 $this->linkAllPosts ($wpQuery, $graph, $account_resource, 'sioc:creator_of'); 98 return $graph; 99 } 100 101 private function linkAllPosts ($wpQuery, $graph, $resourceToLink, $property) { 75 102 while ($wpQuery->have_posts ()) { 76 103 $wpQuery->next_post (); … … 79 106 $post_resource = $graph->resource ($post_uri, 'sioct:BlogPost'); 80 107 $post_resource->set ('dc:title', $post->post_title); 81 $author_resource->add ('foaf:publications', $post_resource); 108 $resourceToLink->add ($property, $post_resource); 109 } 110 } 82 111 83 } 112 private function buildGraphForBlog ($graph, $wpQuery) { 113 $blogUri = $this->getBlogUri (); 114 $blogResource = $graph->resource ($blogUri, 'sioct:Weblog'); 115 $blogResource->set ('rdfs:label', get_bloginfo('name') ?: null); 116 $blogResource->set ('rdfs:comment', get_bloginfo('description') ?: null); 117 $this->linkAllPosts ($wpQuery, $graph, $blogResource, 'sioc:container_of'); 84 118 return $graph; 85 119 } 86 120 121 private function getBlogUri () { 122 return site_url () . '#it'; 123 } 124 87 125 } -
wp-linked-data/trunk/wp-linked-data.php
r705406 r715544 2 2 /* 3 3 Plugin Name: wp-linked-data 4 Plugin URI: http:// datenwissen.de4 Plugin URI: http://wordpress.org/extend/plugins/wp-linked-data/ 5 5 Description: Publishing blog contents as linked data 6 Version: 0. 16 Version: 0.2 7 7 Author: Angelo Veltens 8 8 Author URI: http://me.desone.org/person/aveltens#me
Note: See TracChangeset
for help on using the changeset viewer.