本文整理汇总了PHP中SMW\DIProperty::getDiWikiPage方法的典型用法代码示例。如果您正苦于以下问题:PHP DIProperty::getDiWikiPage方法的具体用法?PHP DIProperty::getDiWikiPage怎么用?PHP DIProperty::getDiWikiPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\DIProperty
的用法示例。
在下文中一共展示了DIProperty::getDiWikiPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPredefinedProperty
public function testPredefinedProperty()
{
$instance = new HashBuilder();
$property = new DIProperty('_MDAT');
$dataItem = $property->getDiWikiPage();
$this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->getHashIdForDiWikiPage($dataItem)));
$this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->createHashIdFromSegments($property->getKey(), SMW_NS_PROPERTY)));
}
示例2: findBasePropertyToRedirectFor
private function findBasePropertyToRedirectFor($label)
{
$property = new DIProperty(PropertyRegistry::getInstance()->findPropertyIdByLabel($label));
if ($property->getLabel() !== '' && $label !== $property->getLabel()) {
$outputPage = $this->getContext()->getOutput();
$outputPage->redirect($property->getDiWikiPage()->getTitle()->getFullURL());
}
}
示例3: tryToFindAtLeastOneReferenceForProperty
/**
* @since 2.4
*
* @param DIProperty $property
*
* @return DataItem|false
*/
public function tryToFindAtLeastOneReferenceForProperty(DIProperty $property)
{
$dataItem = $property->getDiWikiPage();
$sid = $this->store->getObjectIds()->getSMWPageID($dataItem->getDBkey(), $dataItem->getNamespace(), $dataItem->getInterwiki(), '');
// Lets see if we have some lower/upper case matching for
// when wgCapitalLinks setting was involved
if (!$this->usesCapitalLinks && $sid == 0) {
$sid = $this->store->getObjectIds()->getSMWPageID(lcfirst($dataItem->getDBkey()), $dataItem->getNamespace(), $dataItem->getInterwiki(), '');
}
return $this->tryToFindAtLeastOneReferenceForId($sid);
}
示例4: testFindSubpropertyList
public function testFindSubpropertyList()
{
$property = new DIProperty('Foo');
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$store->expects($this->once())->method('getPropertySubjects')->with($this->equalTo(new DIProperty('_SUBP')), $this->equalTo($property->getDiWikiPage()), $this->anything())->will($this->returnValue(array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY))));
$cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMock();
$cache->expects($this->once())->method('contains')->will($this->returnValue(false));
$cache->expects($this->once())->method('save')->with($this->equalTo('_SUBP#Foo#-1#0##1##1#'), $this->anything());
$instance = new PropertyHierarchyLookup($store, $cache);
$expected = array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY));
$this->assertEquals($expected, $instance->findSubpropertListFor($property));
}
示例5: testUseInterwikiPrefix
public function testUseInterwikiPrefix()
{
$property = new DIProperty('Foo');
$property->setInterwiki('bar');
$this->assertEquals(new \SMW\DiWikiPage('Foo', SMW_NS_PROPERTY, 'bar'), $property->getDiWikiPage());
}
示例6: 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);
}
示例7: addPropertyHierarchy
private function addPropertyHierarchy(DIProperty $property, $targetHierarchy)
{
$semanticData = $this->semanticDataFactory->setSubject($property->getDiWikiPage())->newEmptySemanticData();
$semanticData->addDataValue($this->dataValueFactory->newPropertyObjectValue(new DIProperty('_SUBP'), $targetHierarchy));
$this->getStore()->updateData($semanticData);
}
示例8: hasSubpropertyFor
/**
* @note There are different ways to find out whether a property
* has a subproperty or not.
*
* In SPARQL one could try using FILTER NOT EXISTS { ?s my:property ?o }
*
* @since 2.3
*
* @param DIProperty $property
*
* @return boolean
*/
public function hasSubpropertyFor(DIProperty $property)
{
return $this->hasMatchFor('_SUBP', $property->getKey(), $property->getDiWikiPage());
}
示例9: fetchCachedConversionData
/**
* @since 2.4
*
* @param DIProperty|null $property
*/
public function fetchCachedConversionData(DIProperty $property = null)
{
if ($property === null || ($propertyDiWikiPage = $property->getDiWikiPage()) === null) {
return;
}
$blobStore = $this->cachedPropertyValuesPrefetcher->getBlobStore();
// Ensure that when the property page is altered the cache gets
// evicted
$hash = $this->cachedPropertyValuesPrefetcher->getRootHashFrom($propertyDiWikiPage);
$container = $blobStore->read($hash);
$key = '--conv';
if ($container->has($key)) {
$data = $container->get($key);
$this->unitIds = $data['ids'];
$this->unitFactors = $data['factors'];
$this->mainUnit = $data['main'];
$this->prefixalUnitPreference = $data['prefix'];
return;
}
$this->fetchConversionData($property);
if ($this->errors !== array()) {
return;
}
$data = array('ids' => $this->unitIds, 'factors' => $this->unitFactors, 'main' => $this->mainUnit, 'prefix' => $this->prefixalUnitPreference);
$container->set($key, $data);
$blobStore->save($container);
}
示例10: getUserDefinedPropertyInfo
/**
* Returns information related to user-defined properties
*
* @since 1.9
*
* @param Title $title
* @param DIProperty $property
* @param integer $useCount
*
* @return array
*/
private function getUserDefinedPropertyInfo($title, $property, $useCount)
{
if ($useCount <= $this->settings->get('smwgPropertyLowUsageThreshold')) {
$this->getMessageFormatter()->addFromKey('smw_propertyhardlyused');
}
// User defined types default to Page
$typestring = SMWTypesValue::newFromTypeId($this->settings->get('smwgPDefaultType'))->getLongHTMLText($this->getLinker());
$label = htmlspecialchars($property->getLabel());
if ($title->exists()) {
$typeProperty = new DIProperty('_TYPE');
$types = $this->store->getPropertyValues($property->getDiWikiPage(), $typeProperty);
if (count($types) >= 1) {
$typeDataValue = DataValueFactory::getInstance()->newDataItemValue(current($types), $typeProperty);
$typestring = $typeDataValue->getLongHTMLText($this->getLinker());
} else {
$this->getMessageFormatter()->addFromKey('smw_propertylackstype', $typestring);
}
$proplink = $this->getLinker()->link($title, $label);
} else {
$this->getMessageFormatter()->addFromKey('smw_propertylackspage');
$proplink = $this->getLinker()->link($title, $label, array(), array('action' => 'view'));
}
return array($typestring, $proplink);
}
示例11: getDependencies
/**
* @since 2.1
*
* @return SemanticData
*/
public function getDependencies()
{
$semanticData = new SemanticData($this->property->getDiWikiPage());
$semanticData->addDataValue(DataValueFactory::getInstance()->newPropertyObjectValue(new DIProperty('_TYPE'), $this->property->findPropertyTypeID()));
return $semanticData;
}
示例12: 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
*
* @return ExpResource
* @throws RuntimeException
*/
public function mapPropertyToResourceElement(DIProperty $property, $useAuxiliaryModifier = false)
{
$diWikiPage = $property->getDiWikiPage();
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;
}
return $this->mapWikiPageToResourceElement($diWikiPage, $useAuxiliaryModifier);
}
示例13: formatPropertyItem
/**
* Produce a formatted string representation for showing a property and
* its usage count in the list of used properties.
*
* @since 1.8
*
* @param DIProperty $property
* @param integer $useCount
* @return string
*/
protected function formatPropertyItem(DIProperty $property, $useCount)
{
// Clear formatter before invoking messages
$this->getMessageFormatter()->clear();
$diWikiPage = $property->getDiWikiPage();
$title = $diWikiPage !== null ? $diWikiPage->getTitle() : null;
if ($useCount == 0 && !$this->settings->get('smwgPropertyZeroCountDisplay')) {
return '';
}
if ($property->isUserDefined()) {
if ($title === null) {
// Show even messed up property names.
$typestring = '';
$proplink = $property->getLabel();
$this->getMessageFormatter()->addFromArray(array('ID: ' . (isset($property->id) ? $property->id : 'N/A')))->addFromKey('smw_notitle', $proplink);
} else {
list($typestring, $proplink) = $this->getUserDefinedPropertyInfo($title, $property, $useCount);
}
$infoLink = '';
// Add a link to SearchByProperty to hopefully identify the
// "hidden" reference
if ($useCount < 1) {
$infoLink = ' ' . \SMWInfolink::newPropertySearchLink('+', $property->getLabel(), '')->getHTML($this->getLinker());
}
$proplink .= $infoLink;
} else {
list($typestring, $proplink) = $this->getPredefinedPropertyInfo($property);
}
if ($typestring === '') {
// Built-ins have no type
// @todo Should use numParams for $useCount?
return $this->msg('smw_property_template_notype')->rawParams($proplink)->numParams($useCount)->text() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
} else {
// @todo Should use numParams for $useCount?
return $this->msg('smw_property_template')->rawParams($proplink, $typestring)->numParams($useCount)->escaped() . ' ' . $this->getMessageFormatter()->setType('warning')->escape(false)->getHtml();
}
}
示例14: 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 $markForAuxiliaryUsage 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 $markForAuxiliaryUsage
*
* @return ExpResource
* @throws RuntimeException
*/
public function mapPropertyToResourceElement(DIProperty $property, $markForAuxiliaryUsage = false)
{
$diWikiPage = $property->getDiWikiPage();
if ($diWikiPage !== null) {
return $this->mapWikiPageToResourceElement($diWikiPage, $markForAuxiliaryUsage);
}
throw new RuntimeException('Only non-inverse, user-defined properties are permitted.');
}
示例15: findPropertyDataItems
private function findPropertyDataItems(DIProperty $property = null)
{
if ($property === null) {
return array();
}
$propertyDiWikiPage = $property->getDiWikiPage();
if ($propertyDiWikiPage === null) {
return array();
}
$listDiProperty = new DIProperty('_LIST');
$dataItems = ApplicationFactory::getInstance()->getStore()->getPropertyValues($propertyDiWikiPage, $listDiProperty);
if (count($dataItems) == 1) {
$propertyListValue = new PropertyListValue('__pls');
$propertyListValue->setDataItem(reset($dataItems));
if ($propertyListValue->isValid()) {
return $propertyListValue->getPropertyDataItems();
}
}
return array();
}