Пример #1
0
 /**
  * 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;
         }
     }
 }
Пример #2
0
 /**
  * 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;
     }
 }
 /**
  * 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;
         }
     }
 }