本文整理汇总了PHP中SMW\DIProperty::getCanonicalDiWikiPage方法的典型用法代码示例。如果您正苦于以下问题:PHP DIProperty::getCanonicalDiWikiPage方法的具体用法?PHP DIProperty::getCanonicalDiWikiPage怎么用?PHP DIProperty::getCanonicalDiWikiPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\DIProperty
的用法示例。
在下文中一共展示了DIProperty::getCanonicalDiWikiPage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findPropertyIdByLabel
private function findPropertyIdByLabel($label)
{
$property = new DIProperty(PropertyRegistry::getInstance()->findPropertyIdByLabel($label));
$canonicalLabel = $property->getCanonicalLabel();
// #1966 and #1968
// In case something goes wrong, a recursive loop will kill PHP
// and we know we messed up
if ($canonicalLabel !== '' && $label !== $canonicalLabel) {
$this->findPropertyIdByLabel($property->getCanonicalDiWikiPage()->getTitle()->getText());
}
return array($label, $property);
}
示例2: addResourceValue
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function addResourceValue(ExpData $expData, DIProperty $property, DataItem $dataItem)
{
$expElement = $this->exporter->getDataItemExpElement($dataItem);
if ($expElement === null) {
return;
}
if ($property->getKey() === $property->findPropertyTypeID()) {
// Ensures that Boolean remains Boolean and not localized canonical
// representation such as "Booléen" when the content languageis not
// English
$expNsResource = $this->getResourceElementForProperty(new DIProperty($property->getCanonicalDiWikiPage()->getDBKey()));
} else {
$expNsResource = $this->getResourceElementHelperForProperty($property);
}
$expData->addPropertyObjectValue($expNsResource, $expElement);
$this->addResourceHelperValue($expData, $property, $dataItem);
}
示例3: addResourceValue
/**
* @since 2.5
*
* {@inheritDoc}
*/
public function addResourceValue(ExpData $expData, DIProperty $property, DataItem $dataItem)
{
$expResourceElement = $this->exporter->getResourceElementForWikiPage($property->getCanonicalDiWikiPage(), true);
// Avoid that an imported vocabulary is pointing to an internal resource.
//
// For example: <Has_alternative_label> imported from <skos:altLabel>
// with "Monolingual text" type is expected to produce:
//
// - <property:Has_alternative_label rdf:resource="http://example.org/id/Foo_MLa9c103f4379a94bfab97819dacd3c182"/>
// - <skos:altLabel xml:lang="en">Foo</skos:altLabel>
if ($expResourceElement->isImported()) {
$seekImportVocabulary = false;
$expData->addPropertyObjectValue($this->exporter->getResourceElementForProperty($property, false, $seekImportVocabulary), $this->exporter->getDataItemExpElement($dataItem));
} else {
parent::addResourceValue($expData, $property, $dataItem);
}
$dataValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $property);
$list = $dataValue->toArray();
if (!isset($list['_TEXT']) || !isset($list['_LCODE'])) {
return;
}
$expData->addPropertyObjectValue($expResourceElement, new ExpLiteral((string) $list['_TEXT'], 'http://www.w3.org/2001/XMLSchema#string', (string) $list['_LCODE'], $dataItem));
}
示例4: dataItemFromDBKeys
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function dataItemFromDBKeys($dbkeys)
{
if (is_array($dbkeys) && count($dbkeys) == 5) {
$namespace = intval($dbkeys[1]);
if ($namespace == SMW_NS_PROPERTY && $dbkeys[0] != '' && $dbkeys[0][0] == '_' && $dbkeys[2] == '') {
// Correctly interpret internal property keys
$property = new DIProperty($dbkeys[0]);
$wikipage = $property->getCanonicalDiWikiPage($dbkeys[4]);
if (!is_null($wikipage)) {
return $wikipage;
}
} else {
return $this->newDiWikiPage($dbkeys);
}
}
throw new DataItemHandlerException('Failed to create data item from DB keys.');
}
示例5: doMatchProperty
private function doMatchProperty(&$subjects, DIProperty $property)
{
if ($property->isInverse()) {
$property = new DIProperty($property->getKey());
}
$subject = $property->getCanonicalDiWikiPage();
if ($this->propertyHierarchyLookup->hasSubpropertyFor($property)) {
$this->doMatchSubproperty($subjects, $subject, $property);
}
// Use the key here do match against pre-defined properties (e.g. _MDAT)
$key = str_replace(' ', '_', $property->getKey());
if (!isset($this->propertyDependencyExemptionlist[$key])) {
$subjects[$subject->getHash()] = $subject;
}
}
示例6: testCanonicalRepresentation
public function testCanonicalRepresentation()
{
$property = new DIProperty('_MDAT');
$this->assertEquals('Modification date', $property->getCanonicalLabel());
$this->assertEquals(new DIWikiPage('Modification_date', SMW_NS_PROPERTY), $property->getCanonicalDiWikiPage());
}
示例7: getPropertyIdBy
/**
* @since 2.5
*
* @param DIProperty $property
*
* @return integer
*/
public function getPropertyIdBy(DIProperty $property)
{
return $this->store->getObjectIds()->getIDFor($property->getCanonicalDiWikiPage());
}
示例8: getPropertyDescriptionBy
/**
* We try to cache anything to avoid unnecessary store connections or DB
* lookups. For cases where a property was changed, the EventDipatcher will
* receive a 'property.specification.change' event (emitted as soon as the content of
* a property page was altered) with PropertySpecificationLookup::resetCacheBy
* being invoked to remove the cache entry for that specific property.
*
* @since 2.4
*
* @param DIProperty $property
* @param mixed|null $linker
* @param string $languageCode
*
* @return string
*/
public function getPropertyDescriptionBy(DIProperty $property, $linker = null, $languageCode = '')
{
// Take the linker into account (Special vs. in page rendering etc.)
$languageCode = $languageCode === '' ? $this->languageCode : $languageCode;
$key = '--pdesc:' . $languageCode . ':' . ($linker === null ? '0' : '1');
$blobStore = $this->cachedPropertyValuesPrefetcher->getBlobStore();
$container = $blobStore->read($this->cachedPropertyValuesPrefetcher->getRootHashFrom($property->getCanonicalDiWikiPage()));
if ($container->has($key)) {
return $container->get($key);
}
$localPropertyDescription = $this->tryToFindLocalPropertyDescription($property, $linker, $languageCode);
// If a local property description wasn't available for a predefined property
// the try to find a system translation
if (trim($localPropertyDescription) === '' && !$property->isUserDefined()) {
$localPropertyDescription = $this->getPredefinedPropertyDescription($property, $linker, $languageCode);
}
$container->set($key, $localPropertyDescription);
$blobStore->save($container);
return $localPropertyDescription;
}
示例9: findBasePropertyToRedirectFor
private function findBasePropertyToRedirectFor($label)
{
$property = new DIProperty(PropertyRegistry::getInstance()->findPropertyIdByLabel($label));
// Ensure to redirect to `Property:Modification date` and not using
// a possible user contextualized version such as `Property:Date de modification`
$canonicalLabel = $property->getCanonicalLabel();
if ($canonicalLabel !== '' && $label !== $canonicalLabel) {
$outputPage = $this->getContext()->getOutput();
$outputPage->redirect($property->getCanonicalDiWikiPage()->getTitle()->getFullURL());
}
}
示例10: mapPropertyToResourceElement
/**
* Create an ExpElement for some internal resource, given by an
* DIProperty object.
*
* This code is only applied to user-defined properties, since the
* code for special properties in
* Exporter::getSpecialPropertyResource may require information
* about the namespace in which some special property is used.
*
* @note $useAuxiliaryModifier is to determine whether an auxiliary
* property resource is to store a helper value
* (see Exporter::getDataItemHelperExpElement) should be generated
*
* @param DIProperty $property
* @param boolean $useAuxiliaryModifier
* @param boolean $seekImportVocabulary
*
* @return ExpResource
* @throws RuntimeException
*/
public function mapPropertyToResourceElement(DIProperty $property, $useAuxiliaryModifier = false, $seekImportVocabulary = true)
{
// We want the a canonical representation to ensure that resources
// are language independent
$this->seekImportVocabulary = $seekImportVocabulary;
$diWikiPage = $property->getCanonicalDiWikiPage();
if ($diWikiPage === null) {
throw new RuntimeException('Only non-inverse, user-defined properties are permitted.');
}
// No need for any aux properties besides those listed here
if (!$this->bcAuxiliaryUse && $property->findPropertyTypeID() !== '_dat' && $property->findPropertyTypeID() !== '_geo') {
$useAuxiliaryModifier = false;
}
$expResource = $this->mapWikiPageToResourceElement($diWikiPage, $useAuxiliaryModifier);
$this->seekImportVocabulary = true;
return $expResource;
}
示例11: newMappingIterator
/**
* Fetch all subobjects for a given subject using a lazy-mapping iterator
* in order to only resolve one subobject per iteration step.
*
* @since 2.5
*
* @param DIWikiPage $subject
*
* @return MappingIterator
*/
private function newMappingIterator(DIWikiPage $subject)
{
$callback = function ($row) use($subject) {
// #1955
if ($subject->getNamespace() === SMW_NS_PROPERTY) {
$property = new DIProperty($subject->getDBkey());
$subobject = $property->getCanonicalDiWikiPage($row->smw_subobject);
} else {
$subobject = new DIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $row->smw_subobject);
}
$subobject->setSortKey($row->smw_sortkey);
$subobject->setId($row->smw_id);
return $subobject;
};
return $this->iteratorFactory->newMappingIterator($this->newResultIterator($subject), $callback);
}