Пример #1
0
 public function build()
 {
     global $wgSitename, $wgContLanguageCode;
     $article = $this->Agent->getArticle();
     $model = MwRdf::Model();
     $rdf = MwRdf::Vocabulary('rdf');
     $dc = MwRdf::Vocabulary('dc');
     $dctype = MwRdf::Vocabulary('dctype');
     $artres = $this->Agent->titleResource();
     $model->addStatement(MwRdf::Statement($artres, $dc->title, MwRdf::LiteralNode($this->Agent->getTitle()->getText())));
     $model->addStatement(MwRdf::Statement($artres, $dc->publisher, MwRdf::PageOrString(wfMsg('aboutpage'), $wgSitename)));
     $model->addStatement(MwRdf::Statement($artres, $dc->language, MwRdf::Language($wgContLanguageCode)));
     $model->addStatement(MwRdf::Statement($artres, $dc->type, $dctype->Text));
     $model->addStatement(MwRdf::Statement($artres, $dc->format, MwRdf::MediaType('text/html')));
     if ($this->Agent->getTimestampResource()) {
         $model->addStatement(MwRdf::Statement($artres, $dc->date, $this->Agent->getTimestampResource()));
     }
     if (MWNamespace::isTalk($this->Agent->getTitle()->getNamespace())) {
         $model->addStatement(MwRdf::Statement($artres, $dc->subject, $this->Agent->subjectResource()));
     } else {
         $talk = MwRdf::ModelingAgent($this->Agent->getTitle()->getTalkPage());
         $model->addStatement(MwRdf::Statement($talk->titleResource(), $dc->subject, $artres));
     }
     # 'Creator' is responsible for this version
     $creator = MwRdf::PersonToResource($article->getUser());
     $model->addStatement(MwRdf::Statement($artres, $dc->creator, $creator));
     # 'Contributors' are all other version authors
     $contributors = $article->getContributors();
     foreach ($contributors as $user_parts) {
         $contributor = MwRdf::PersonToResource($user_parts[0], $user_parts[1], $user_parts[2]);
         $model->addStatement(MwRdf::Statement($artres, $dc->contributor, $contributor));
     }
     # Rights notification
     global $wgRightsPage, $wgRightsUrl, $wgRightsText;
     $rights = MwRdf::RightsResource();
     if ($rights) {
         $model->addStatement(MwRdf::Statement($artres, $dc->rights, $rights));
     }
     return $model;
 }
Пример #2
0
 public function testRightsResource_NoSetting()
 {
     global $wgRightsPage, $wgRightsUrl, $wgRightsText;
     $wgRightsPage = null;
     $wgRightsUrl = null;
     $wgRightsText = null;
     $this->assertType("boolean", MwRdf::RightsResource());
     $this->assertFalse(MwRdf::RightsResource());
 }