本文整理汇总了PHP中SMWDIProperty::isUserDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDIProperty::isUserDefined方法的具体用法?PHP SMWDIProperty::isUserDefined怎么用?PHP SMWDIProperty::isUserDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDIProperty
的用法示例。
在下文中一共展示了SMWDIProperty::isUserDefined方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeSMWPropertyID
/**
* This function does the same as makeSMWPageID() but takes into account
* that properties might be predefined.
*/
protected function makeSMWPropertyID(SMWDIProperty $property)
{
if (!$property->isUserDefined() && array_key_exists($property->getKey(), self::$special_ids)) {
return self::$special_ids[$property->getKey()];
// very important property with fixed id
} else {
return $this->makeSMWPageID($property->getKey(), SMW_NS_PROPERTY, $this->getPropertyInterwiki($property), '', true);
}
}
示例2: addPropertyObjectValue
/**
* Store a value for a property identified by its SMWDataItem object.
*
* @note There is no check whether the type of the given data item
* agrees with the type of the property. Since property types can
* change, all parts of SMW are prepared to handle mismatched data item
* types anyway.
*
* @param $property SMWDIProperty
* @param $dataItem SMWDataItem
*/
public function addPropertyObjectValue(SMWDIProperty $property, SMWDataItem $dataItem)
{
if ($dataItem instanceof SMWDIContainer) {
$this->addSubSemanticData($dataItem->getSemanticData());
$dataItem = $dataItem->getSemanticData()->getSubject();
}
if ($property->isInverse()) {
// inverse properties cannot be used for annotation
return;
}
if (!array_key_exists($property->getKey(), $this->mPropVals)) {
$this->mPropVals[$property->getKey()] = array();
$this->mProperties[$property->getKey()] = $property;
}
if ($this->mNoDuplicates) {
$this->mPropVals[$property->getKey()][$dataItem->getHash()] = $dataItem;
} else {
$this->mPropVals[$property->getKey()][] = $dataItem;
}
if (!$property->isUserDefined()) {
if ($property->isShown()) {
$this->mHasVisibleSpecs = true;
$this->mHasVisibleProps = true;
}
} else {
$this->mHasVisibleProps = true;
}
}
示例3: addPropertyValues
/**
* Extend a given SMWExpData element by adding export data for the
* specified property data itme. This method is called when
* constructing export data structures from SMWSemanticData objects.
*
* @param $property SMWDIProperty
* @param $dataItems array of SMWDataItem objects for the given property
* @param $data SMWExpData to add the data to
*/
public static function addPropertyValues(SMWDIProperty $property, array $dataItems, SMWExpData &$expData)
{
if ($property->isUserDefined()) {
$pe = self::getResourceElementForProperty($property);
$peHelper = self::getResourceElementForProperty($property, true);
foreach ($dataItems as $dataItem) {
$ed = self::getDataItemExpElement($dataItem);
if (!is_null($ed)) {
$expData->addPropertyObjectValue($pe, $ed);
}
$edHelper = self::getDataItemHelperExpElement($dataItem);
if (!is_null($edHelper)) {
$expData->addPropertyObjectValue($peHelper, $edHelper);
}
}
} else {
// pre-defined property, only exported if known
$diSubject = $expData->getSubject()->getDataItem();
// subject wikipage required for disambiguating special properties:
if (is_null($diSubject) || $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE) {
return;
}
$pe = self::getSpecialPropertyResource($property->getKey(), $diSubject->getNamespace());
if (is_null($pe)) {
return;
}
// unknown special property, not exported
// have helper property ready before entering the for loop, even if not needed:
$peHelper = self::getResourceElementForProperty($property, true);
$filterNamespace = $property->getKey() == '_REDI' || $property->getKey() == '_URI';
foreach ($dataItems as $dataItem) {
// Basic namespace filtering to ensure that types match for redirects etc.
/// TODO: currently no full check for avoiding OWL DL illegal redirects is done (OWL property type ignored)
if ($filterNamespace && !$dataItem instanceof SMWDIUri && (!$dataItem instanceof SMWDIWikiPage || $dataItem->getNamespace() != $diSubject->getNamespace())) {
continue;
}
$ed = self::getDataItemExpElement($dataItem);
if (!is_null($ed)) {
if ($property->getKey() == '_CONC' && $ed->getSubject()->getUri() === '') {
// equivalent to anonymous class -> simplify description
foreach ($ed->getProperties() as $subp) {
if ($subp->getUri() != self::getSpecialNsResource('rdf', 'type')->getUri()) {
foreach ($ed->getValues($subp) as $subval) {
$expData->addPropertyObjectValue($subp, $subval);
}
}
}
} elseif ($property->getKey() == '_REDI') {
$expData->addPropertyObjectValue($pe, $ed);
$peUri = self::getSpecialPropertyResource('_URI');
$expData->addPropertyObjectValue($peUri, $ed);
} else {
$expData->addPropertyObjectValue($pe, $ed);
}
}
$edHelper = self::getDataItemHelperExpElement($dataItem);
if (!is_null($edHelper)) {
$expData->addPropertyObjectValue($peHelper, $edHelper);
}
}
}
}
示例4: unstubProperty
/**
* Unstub a single property from the stub data array. If available, an
* existing object for that property might be provided, so we do not
* need to make a new one. It is not checked if the object matches the
* property name.
*
* @param $propertyKey string
* @param $diProperty SMWDIProperty
*/
protected function unstubProperty($propertyKey, $diProperty = null)
{
if (!array_key_exists($propertyKey, $this->mProperties)) {
if (is_null($diProperty)) {
//$propertyDV = SMWPropertyValue::makeProperty( $propertyKey );
//$diProperty = $propertyDV->getDataItem();
$diProperty = new SMWDIProperty($propertyKey, false);
}
$this->mProperties[$propertyKey] = $diProperty;
if (!$diProperty->isUserDefined()) {
if ($diProperty->isShown()) {
$this->mHasVisibleSpecs = true;
$this->mHasVisibleProps = true;
}
} else {
$this->mHasVisibleProps = true;
}
}
}
示例5: unstubProperty
/**
* Unstub a single property from the stub data array. If available, an
* existing object for that property might be provided, so we do not
* need to make a new one. It is not checked if the object matches the
* property name.
*
* @since 1.8
*
* @param string $propertyKey
* @param SMWDIProperty $diProperty if available
* @throws SMWDataItemException if property key is not valid
* and $diProperty is null
*/
protected function unstubProperty($propertyKey, $diProperty = null)
{
if (!array_key_exists($propertyKey, $this->mProperties)) {
if (is_null($diProperty)) {
$diProperty = new SMWDIProperty($propertyKey, false);
}
$this->mProperties[$propertyKey] = $diProperty;
if (!$diProperty->isUserDefined()) {
if ($diProperty->isShown()) {
$this->mHasVisibleSpecs = true;
$this->mHasVisibleProps = true;
}
} else {
$this->mHasVisibleProps = true;
}
}
}
示例6: formatPropertyItem
/**
* Produce a formatted string representation for showing a property in
* the list of unused properties.
*
* @since 1.8
*
* @param SMWDIProperty $property
* @return string
*/
protected function formatPropertyItem(SMWDIProperty $property)
{
$linker = smwfGetLinker();
$errors = array();
if ($property->isUserDefined()) {
$proplink = $linker->link($property->getDiWikiPage()->getTitle(), $property->getLabel());
$types = smwfGetStore()->getPropertyValues($property->getDiWikiPage(), new SMWDIProperty('_TYPE'));
if (count($types) >= 1) {
$typeDataValue = SMWDataValueFactory::newDataItemValue(current($types), new SMWDIProperty('_TYPE'));
} else {
$typeDataValue = SMWTypesValue::newFromTypeId('_wpg');
$errors[] = wfMessage('smw_propertylackstype', $typeDataValue->getLongHTMLText())->text();
}
$typeString = $typeDataValue->getLongHTMLText($linker);
} else {
$typeid = $property->findPropertyTypeID();
$typeDataValue = SMWTypesValue::newFromTypeId($typeid);
$typeString = $typeDataValue->getLongHTMLText($linker);
$propertyDataValue = SMWDataValueFactory::newDataItemValue($property, null);
$proplink = $propertyDataValue->getShortHtmlText($linker);
}
return wfMessage('smw_unusedproperty_template', $proplink, $typeString)->text() . ' ' . smwfEncodeMessages($errors);
}
示例7: formatPropertyItem
/**
* Produce a formatted string representation for showing a property and
* its usage count in the list of used properties.
*
* @since 1.8
*
* @param SMWDIProperty $property
* @param integer $useCount
* @return string
*/
protected function formatPropertyItem(SMWDIProperty $property, $useCount)
{
global $wgLang;
$linker = smwfGetLinker();
$errors = array();
$diWikiPage = $property->getDiWikiPage();
$title = !is_null($diWikiPage) ? $diWikiPage->getTitle() : null;
if ($property->isUserDefined() && is_null($title)) {
// Show even messed up property names.
$typestring = '';
$proplink = $property->getLabel();
$errors[] = wfMessage('smw_notitle', $property->getLabel())->escaped();
} elseif ($property->isUserDefined()) {
if ($useCount <= 5) {
$errors[] = wfMessage('smw_propertyhardlyused')->escaped();
}
// User defined types default to Page
global $smwgPDefaultType;
$typeDataValue = SMWTypesValue::newFromTypeId($smwgPDefaultType);
$typestring = $typeDataValue->getLongHTMLText($linker);
$label = htmlspecialchars($property->getLabel());
if ($title->exists()) {
$typeProperty = new SMWDIProperty('_TYPE');
$types = smwfGetStore()->getPropertyValues($diWikiPage, $typeProperty);
if (count($types) >= 1) {
$typeDataValue = SMWDataValueFactory::newDataItemValue(current($types), $typeProperty);
$typestring = $typeDataValue->getLongHTMLText($linker);
} else {
$errors[] = wfMessage('smw_propertylackstype')->rawParams($typestring)->escaped();
}
$proplink = $linker->link($title, $label);
} else {
$errors[] = wfMessage('smw_propertylackspage')->escaped();
$proplink = $linker->link($title, $label, array(), array('action' => 'view'));
}
} else {
// predefined property
$typeid = $property->findPropertyTypeID();
$typeDataValue = SMWTypesValue::newFromTypeId($typeid);
$typestring = $typeDataValue->getLongHTMLText($linker);
$propertyDataValue = SMWDataValueFactory::newDataItemValue($property, null);
$proplink = $propertyDataValue->getShortHtmlText($linker);
}
$warnings = smwfEncodeMessages($errors, 'warning', '', false);
$useCount = $wgLang->formatNum($useCount);
if ($typestring === '') {
// Builtins have no type
// @todo Should use numParams for $useCount?
return wfMessage('smw_property_template_notype')->rawParams($proplink)->params($useCount)->text() . ' ' . $warnings;
} else {
// @todo Should use numParams for $useCount?
return wfMessage('smw_property_template')->rawParams($proplink, $typestring)->params($useCount)->escaped() . ' ' . $warnings;
}
}
示例8: addPropertyValues
/**
* Extend a given SMWExpData element by adding export data for the
* specified property data itme. This method is called when
* constructing export data structures from SMWSemanticData objects.
*
* @param $property SMWDIProperty
* @param $dataItems array of SMWDataItem objects for the given property
* @param $data SMWExpData to add the data to
*/
static public function addPropertyValues( SMWDIProperty $property, array $dataItems, SMWExpData &$expData ) {
if ( $property->isUserDefined() ) {
$pe = self::getResourceElementForProperty( $property );
$peHelper = self::getResourceElementForProperty( $property, true );
foreach ( $dataItems as $dataItem ) {
$ed = self::getDataItemExpElement( $dataItem );
if ( !is_null( $ed ) ) {
$expData->addPropertyObjectValue( $pe, $ed );
}
$edHelper = self::getDataItemHelperExpElement( $dataItem );
if ( !is_null( $edHelper ) ) {
$expData->addPropertyObjectValue( $peHelper, $edHelper );
}
}
} else { // pre-defined property, only exported if known
$diSubject = $expData->getSubject()->getDataItem();
if ( ( $diSubject == null ) || ( $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) ) {
return; // subject datavalue (wikipage) required for treating special properties properly
}
$pe = self::getSpecialPropertyResource( $property->getKey(), $diSubject->getNamespace() );
if ( is_null( $pe ) ) return; // unknown special property, not exported
if ( $property->getKey() == '_REDI' || $property->getKey() == '_URI' ) {
$filterNamespace = true;
if ( $property->getKey() == '_REDI' ) {
$pe = array( $pe, self::getSpecialPropertyResource( '_URI' ) );
}
} else {
$filterNamespace = false;
}
foreach ( $dataItems as $dataItem ) {
// Basic namespace filtering to ensure that types match for redirects etc.
/// TODO: currently no full check for avoiding OWL DL illegal redirects is done (OWL property type ignored)
if ( $filterNamespace && !( $dataItem instanceof SMWDIUri ) &&
( !( $dataItem instanceof SMWDIWikiPage ) ||
( $dataItem->getNamespace() != $diSubject->getNamespace() ) ) ) {
continue;
}
$ed = self::getDataItemExpElement( $dataItem );
if ( !is_null( $ed ) ) {
if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getUri() === '' ) ) {
// equivalent to anonymous class -> simplify description
foreach ( $ed->getProperties() as $subp ) {
if ( $subp->getUri() != self::getSpecialNsResource( 'rdf', 'type' )->getUri() ) {
foreach ( $ed->getValues( $subp ) as $subval ) {
$expData->addPropertyObjectValue( $subp, $subval );
}
}
}
} elseif ( is_array( $pe ) ) {
foreach ( $pe as $extraPropertyElement ) {
$expData->addPropertyObjectValue( $extraPropertyElement, $ed );
}
} else {
$expData->addPropertyObjectValue( $pe, $ed );
}
}
}
}
}