本文整理汇总了PHP中SMWExporter::getSpecialPropertyResource方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWExporter::getSpecialPropertyResource方法的具体用法?PHP SMWExporter::getSpecialPropertyResource怎么用?PHP SMWExporter::getSpecialPropertyResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWExporter
的用法示例。
在下文中一共展示了SMWExporter::getSpecialPropertyResource方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mapCategoriesToConditionElements
private function mapCategoriesToConditionElements(array $categories, $joinVariable)
{
$condition = '';
$namespaces = array();
$instExpElement = $this->exporter->getSpecialPropertyResource('_INST');
foreach ($categories as $category) {
$categoryExpElement = $this->exporter->getResourceElementForWikiPage($category);
$categoryName = TurtleSerializer::getTurtleNameForExpElement($categoryExpElement);
$namespaces[$categoryExpElement->getNamespaceId()] = $categoryExpElement->getNamespace();
$newcondition = "{ ?{$joinVariable} " . $instExpElement->getQName() . " {$categoryName} . }\n";
if ($condition === '') {
$condition = $newcondition;
} else {
$condition .= "UNION\n{$newcondition}";
}
}
return array($condition, $namespaces);
}
示例2: tryToAddPropertyPathForSaturatedHierarchy
/**
* @note rdfs:subPropertyOf* where * means a property path of arbitrary length
* can be found using the "zero or more" will resolve the complete path
*
* @see http://www.w3.org/TR/sparql11-query/#propertypath-arbitrary-length
*/
private function tryToAddPropertyPathForSaturatedHierarchy(&$condition, DIProperty $property, &$propertyName)
{
if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBP) || !$property->isUserDefined()) {
return null;
}
if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() == null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubpropertyFor($property)) {
return null;
}
$subPropExpElement = $this->exporter->getSpecialPropertyResource('_SUBP', SMW_NS_PROPERTY);
$propertyByVariable = '?' . $this->compoundConditionBuilder->getNextVariable('sp');
$condition->weakConditions[$propertyName] = "\n" . "{$propertyByVariable} " . $subPropExpElement->getQName() . "*" . " {$propertyName} .\n" . "";
$propertyName = $propertyByVariable;
}
示例3: tryToAddClassHierarchyPattern
private function tryToAddClassHierarchyPattern($category, &$categoryExpName)
{
if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBC)) {
return '';
}
if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() === null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubcategoryFor($category)) {
return '';
}
$subClassExpElement = $this->exporter->getSpecialPropertyResource('_SUBC');
$classHierarchyByVariable = "?" . $this->compoundConditionBuilder->getNextVariable('sc');
$condition = "{$classHierarchyByVariable} " . $subClassExpElement->getQName() . "*" . " {$categoryExpName} .\n";
$categoryExpName = "{$classHierarchyByVariable}";
return $condition;
}
示例4: addOrderByData
/**
* Extend the given SPARQL condition by a suitable order by variable,
* possibly adding conditions if required for the type of data.
*
* @param SMWSparqlCondition $sparqlCondition condition to modify
* @param string $mainVariable the variable that represents the value to be ordered
* @param integer $diType DataItem type id
*/
protected function addOrderByData(SMWSparqlCondition &$sparqlCondition, $mainVariable, $diType)
{
if ($diType == SMWDataItem::TYPE_WIKIPAGE) {
$sparqlCondition->orderByVariable = $mainVariable . 'sk';
$skeyExpElement = SMWExporter::getSpecialPropertyResource('_SKEY');
$sparqlCondition->weakConditions = array($sparqlCondition->orderByVariable => "?{$mainVariable} " . $skeyExpElement->getQName() . " ?{$sparqlCondition->orderByVariable} .\n");
} else {
$sparqlCondition->orderByVariable = $mainVariable;
}
}
示例5: getSparqlRedirectTarget
/**
* Find the redirect target of an SMWExpNsResource.
* Returns an SMWExpNsResource object the input redirects to,
* the input itself if there is no redirect (or it cannot be
* used for making a resource with a prefix).
*
* @since 1.6
* @param $expNsResource string URI to check
* @param $exists boolean that is set to true if $expNsResource is in the
* store; always false for blank nodes; always true for subobjects
* @return SMWExpNsResource
*/
protected function getSparqlRedirectTarget(SMWExpNsResource $expNsResource, &$exists)
{
if ($expNsResource->isBlankNode()) {
$exists = false;
return $expNsResource;
} elseif ($expNsResource->getDataItem() instanceof SMWDIWikiPage && $expNsResource->getDataItem()->getSubobjectName() !== '') {
$exists = true;
return $expNsResource;
}
$resourceUri = SMWTurtleSerializer::getTurtleNameForExpElement($expNsResource);
$rediUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_REDI'));
$skeyUri = SMWTurtleSerializer::getTurtleNameForExpElement(SMWExporter::getSpecialPropertyResource('_SKEY'));
$sparqlResult = smwfGetSparqlDatabase()->select('*', "{$resourceUri} {$skeyUri} ?s OPTIONAL { {$resourceUri} {$rediUri} ?r }", array('LIMIT' => 1), array($expNsResource->getNamespaceId() => $expNsResource->getNamespace()));
$firstRow = $sparqlResult->current();
if ($firstRow === false) {
$exists = false;
return $expNsResource;
} elseif (count($firstRow) > 1 && !is_null($firstRow[1])) {
$exists = true;
$rediTargetElement = $firstRow[1];
$rediTargetUri = $rediTargetElement->getUri();
$wikiNamespace = SMWExporter::getNamespaceUri('wiki');
if (strpos($rediTargetUri, $wikiNamespace) === 0) {
return new SMWExpNsResource(substr($rediTargetUri, 0, strlen($wikiNamespace)), $wikiNamespace, 'wiki');
} else {
return $expNsResource;
}
} else {
$exists = true;
return $expNsResource;
}
}
示例6: lookupResourceUriTargetFromDatabase
private function lookupResourceUriTargetFromDatabase(ExpNsResource $expNsResource)
{
$resourceUri = TurtleSerializer::getTurtleNameForExpElement($expNsResource);
$rediUri = TurtleSerializer::getTurtleNameForExpElement(Exporter::getSpecialPropertyResource('_REDI'));
$skeyUri = TurtleSerializer::getTurtleNameForExpElement(Exporter::getSpecialPropertyResource('_SKEY'));
$federateResultSet = $this->connection->select('*', "{$resourceUri} {$skeyUri} ?s OPTIONAL { {$resourceUri} {$rediUri} ?r }", array('LIMIT' => 1), array($expNsResource->getNamespaceId() => $expNsResource->getNamespace()));
return $federateResultSet->current();
}
示例7: testExportSubSemanticData
public function testExportSubSemanticData()
{
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$factsheet = $this->fixturesProvider->getFactsheet('berlin');
$factsheet->setTargetSubject($semanticData->getSubject());
$demographicsSubobject = $factsheet->getDemographics();
$semanticData->addPropertyObjectValue($demographicsSubobject->getProperty(), $demographicsSubobject->getContainer());
$exportData = Exporter::makeExportData($semanticData->findSubSemanticData($demographicsSubobject->getSubobjectId()));
$this->assertCount(1, $exportData->getValues(Exporter::getSpecialPropertyResource('_SKEY')));
$this->assertCount(1, $exportData->getValues(Exporter::getSpecialNsResource('swivt', 'wikiNamespace')));
}
示例8: createFilterConditionToMatchRegexPattern
private function createFilterConditionToMatchRegexPattern($dataItem, &$joinVariable, $comparator, $pattern)
{
if ($dataItem instanceof DIBlob) {
return new FilterCondition("{$comparator}( ?{$joinVariable}, \"{$pattern}\", \"s\")", array());
}
if ($dataItem instanceof DIUri) {
return new FilterCondition("{$comparator}( str( ?{$joinVariable} ), \"{$pattern}\", \"i\")", array());
}
// Pattern search for a wikipage object can only be done on the sortkey
// literal and not on it's resource
$skeyExpElement = Exporter::getSpecialPropertyResource('_SKEY');
$expElement = $this->exporter->getDataItemExpElement($dataItem->getSortKeyDataItem());
$condition = new SingletonCondition($expElement);
$filterVariable = $this->compoundConditionBuilder->getNextVariable();
$condition->condition = "?{$joinVariable} " . $skeyExpElement->getQName() . " ?{$filterVariable} .\n";
$condition->matchElement = "?{$joinVariable}";
$filterCondition = new FilterCondition("{$comparator}( ?{$filterVariable}, \"{$pattern}\", \"s\")", array());
$condition->weakConditions = array($filterVariable => $filterCondition->getCondition());
return $condition;
}
示例9: addOrderByData
/**
* Extend the given SPARQL condition by a suitable order by variable,
* possibly adding conditions if required for the type of data.
*
* @param Condition $sparqlCondition condition to modify
* @param string $mainVariable the variable that represents the value to be ordered
* @param integer $diType DataItem type id
*/
public function addOrderByData(Condition &$condition, $mainVariable, $diType)
{
if ($diType !== DataItem::TYPE_WIKIPAGE) {
return $condition->orderByVariable = $mainVariable;
}
$condition->orderByVariable = $mainVariable . 'sk';
$skeyExpElement = Exporter::getSpecialPropertyResource('_SKEY');
$weakConditions = array($condition->orderByVariable => "?{$mainVariable} " . $skeyExpElement->getQName() . " ?{$condition->orderByVariable} .\n");
$condition->weakConditions += $weakConditions;
}