本文整理汇总了PHP中SMWExporter::hasHelperExpElement方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWExporter::hasHelperExpElement方法的具体用法?PHP SMWExporter::hasHelperExpElement怎么用?PHP SMWExporter::hasHelperExpElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWExporter
的用法示例。
在下文中一共展示了SMWExporter::hasHelperExpElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPropertyNameByUsingTurtleSerializer
private function getPropertyNameByUsingTurtleSerializer(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces)
{
// Use helper properties in encoding values, refer to this helper property:
if ($this->exporter->hasHelperExpElement($property)) {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true);
} else {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty);
}
if ($propertyExpElement instanceof ExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
}
示例2: findMostSuitablePropertyRepresentation
private function findMostSuitablePropertyRepresentation(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces)
{
$redirectByVariable = $this->compoundConditionBuilder->tryToFindRedirectVariableForDataItem($nonInverseProperty->getDiWikiPage());
// If the property is represented by a redirect then use the variable instead
if ($redirectByVariable !== null) {
return $redirectByVariable;
}
// Use helper properties in encoding values, refer to this helper property:
if ($this->exporter->hasHelperExpElement($property)) {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true);
} elseif (!$property->isUserDefined()) {
$propertyExpElement = $this->exporter->getSpecialPropertyResource($nonInverseProperty->getKey(), SMW_NS_PROPERTY);
} else {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty);
}
if ($propertyExpElement instanceof ExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
}
示例3: buildPropertyCondition
/**
* Recursively create an SMWSparqlCondition from an SMWSomeProperty.
*
* @param $description SMWSomeProperty
* @param $joinVariable string name, see buildSparqlCondition()
* @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
* @return SMWSparqlCondition
*/
protected function buildPropertyCondition(SMWSomeProperty $description, $joinVariable, $orderByProperty)
{
$diProperty = $description->getProperty();
//*** Find out if we should order by the values of this property ***//
if (array_key_exists($diProperty->getKey(), $this->m_sortkeys)) {
$innerOrderByProperty = $diProperty;
} else {
$innerOrderByProperty = null;
}
//*** Prepare inner condition ***//
$innerJoinVariable = $this->getNextVariable();
$innerCondition = $this->buildSparqlCondition($description->getDescription(), $innerJoinVariable, $innerOrderByProperty);
$namespaces = $innerCondition->namespaces;
if ($innerCondition instanceof SMWSparqlFalseCondition) {
return new SMWSparqlFalseCondition();
} elseif ($innerCondition instanceof SMWSparqlSingletonCondition) {
$matchElement = $innerCondition->matchElement;
$objectName = SMWTurtleSerializer::getTurtleNameForExpElement($matchElement);
if ($matchElement instanceof SMWExpNsResource) {
$namespaces[$matchElement->getNamespaceId()] = $matchElement->getNamespace();
}
} else {
$objectName = '?' . $innerJoinVariable;
}
//*** Exchange arguments when property is inverse ***//
if ($diProperty->isInverse()) {
// don't check if this really makes sense
$subjectName = $objectName;
$objectName = '?' . $joinVariable;
$diNonInverseProperty = new SMWDIProperty($diProperty->getKey(), false);
} else {
$subjectName = '?' . $joinVariable;
$diNonInverseProperty = $diProperty;
}
//*** Build the condition ***//
$typeId = $diProperty->findPropertyTypeID();
$diType = SMWDataValueFactory::getDataItemId($typeId);
// for types that use helper properties in encoding values, refer to this helper property:
if (SMWExporter::hasHelperExpElement($diType)) {
$propertyExpElement = SMWExporter::getResourceElementForProperty($diNonInverseProperty, true);
} else {
$propertyExpElement = SMWExporter::getResourceElementForProperty($diNonInverseProperty);
}
$propertyName = SMWTurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
if ($propertyExpElement instanceof SMWExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
$condition = "{$subjectName} {$propertyName} {$objectName} .\n";
$innerConditionString = $innerCondition->getCondition() . $innerCondition->getWeakConditionString();
if ($innerConditionString !== '') {
if ($innerCondition instanceof SMWSparqlFilterCondition) {
$condition .= $innerConditionString;
} else {
$condition .= "{ {$innerConditionString}}\n";
}
}
$result = new SMWSparqlWhereCondition($condition, true, $namespaces);
//*** Record inner ordering variable if found ***//
$result->orderVariables = $innerCondition->orderVariables;
if (!is_null($innerOrderByProperty) && $innerCondition->orderByVariable !== '') {
$result->orderVariables[$diProperty->getKey()] = $innerCondition->orderByVariable;
}
$this->addOrderByDataForProperty($result, $joinVariable, $orderByProperty, SMWDataItem::TYPE_WIKIPAGE);
return $result;
}
示例4: testExportSubobject
public function testExportSubobject()
{
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$subobject = new Subobject($semanticData->getSubject()->getTitle());
$subobject->setEmptyContainerForId('Foo');
$semanticData->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$exportData = Exporter::makeExportData($semanticData);
$expectedProperty = new ExpNsResource($this->transformPropertyLabelToAuxiliary($subobject->getProperty()), Exporter::getNamespaceUri('property'), 'property', new DIWikiPage('Has_subobject', SMW_NS_PROPERTY));
$this->assertTrue(Exporter::hasHelperExpElement($subobject->getProperty()));
$this->assertCount(1, $exportData->getValues($expectedProperty));
$this->exportDataValidator->assertThatExportDataContainsProperty($expectedProperty, $exportData);
$expectedResource = new ExpNsResource(Exporter::getEncodedPageName($subobject->getSemanticData()->getSubject()) . '-23' . 'Foo', Exporter::getNamespaceUri('wiki'), 'wiki', $subobject->getSemanticData()->getSubject());
$this->exportDataValidator->assertThatExportDataContainsResource($expectedResource, $expectedProperty, $exportData);
}