当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWPropertyValue::getWikiPageValue方法代码示例

本文整理汇总了PHP中SMWPropertyValue::getWikiPageValue方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue::getWikiPageValue方法的具体用法?PHP SMWPropertyValue::getWikiPageValue怎么用?PHP SMWPropertyValue::getWikiPageValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWPropertyValue的用法示例。


在下文中一共展示了SMWPropertyValue::getWikiPageValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllPropertyAnnotations

 /**
  * @see superclass
  */
 function getAllPropertyAnnotations(SMWPropertyValue $property, $requestoptions = NULL)
 {
     global $smwgTripleStoreGraph;
     $client = TSConnection::getConnector();
     $client->connect();
     $values = array();
     $propertyName = $property->getWikiPageValue()->getTitle()->getDBkey();
     $limit = isset($requestoptions->limit) ? " LIMIT " . $requestoptions->limit : "";
     $offset = isset($requestoptions->offset) ? " OFFSET " . $requestoptions->offset : "";
     // query
     $nsPrefixProp = $this->tsNamespace->getNSPrefix($property->getWikiPageValue()->getTitle()->getNamespace());
     try {
         $response = $client->query("SELECT ?s ?o WHERE { GRAPH ?g { ?s <{$smwgTripleStoreGraph}/{$nsPrefixProp}#{$propertyName}> ?o. } } ORDER BY ASC(?s) {$limit} {$offset}", "merge=false");
     } catch (Exception $e) {
         wfDebug("Triplestore does probably not run.\n");
         $response = TSNamespaces::$EMPTY_SPARQL_XML;
     }
     global $smwgSPARQLResultEncoding;
     // PHP strings are always interpreted in ISO-8859-1 but may be actually encoded in
     // another charset.
     if (isset($smwgSPARQLResultEncoding) && $smwgSPARQLResultEncoding == 'UTF-8') {
         $response = utf8_decode($response);
     }
     $dom = simplexml_load_string($response);
     $annotations = array();
     $results = $dom->xpath('//result');
     foreach ($results as $r) {
         $values = array();
         $children = $r->children();
         // binding nodes
         $b = $children->binding[0];
         $sv = $b->children()->uri[0];
         $title = $this->getTitleFromURI((string) $sv);
         $title_dv = SMWDataValueFactory::newTypeIDValue('_wpg');
         $title_dv->setValues($title->getDBkey(), $title->getNamespace(), $title->getArticleID());
         $b = $children->binding[1];
         foreach ($b->children()->uri as $sv) {
             $object = $this->getTitleFromURI((string) $sv);
             $value = SMWDataValueFactory::newPropertyObjectValue($property, $object);
             $metadata = $sv->attributes();
             foreach ($metadata as $mdProperty => $mdValue) {
                 if (strpos($mdProperty, "_meta_") === 0) {
                     $value->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue));
                 }
             }
             $values[] = $value;
         }
         foreach ($b->children()->literal as $sv) {
             $literal = array((string) $sv, $sv->attributes()->datatype);
             $value = $this->getLiteral($literal, $property);
             $metadata = $sv->attributes();
             foreach ($metadata as $mdProperty => $mdValue) {
                 if (strpos($mdProperty, "_meta_") === 0) {
                     $value->setMetadata(substr($mdProperty, 6), explode("|||", $mdValue));
                 }
             }
             $values[] = $value;
         }
         $annotations[] = array($title_dv, $values);
     }
     return $annotations;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:65,代码来源:SMW_TripleStoreQuad.php


注:本文中的SMWPropertyValue::getWikiPageValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。