protected function addDataValuesToSubobject(ParserParameterProcessor $parameters)
 {
     $subject = $this->parserData->getSemanticData()->getSubject();
     // Named subobjects containing a "." in the first five characters are reserved to be
     // used by extensions only in order to separate them from user land and avoid them
     // accidentally to refer to the same named ID
     // (i.e. different access restrictions etc.)
     if (strpos(mb_substr($parameters->getFirst(), 0, 5), '.') !== false) {
         return $this->addErrorWithMsg($subject, wfMessage('smw-subobject-parser-invalid-naming-scheme', $parameters->getFirst())->escaped());
     }
     $this->subobject->setEmptyContainerForId($this->createSubobjectId($parameters));
     foreach ($this->transformParametersToArray($parameters) as $property => $values) {
         if ($property === self::PARAM_SORTKEY) {
             $property = DIProperty::TYPE_SORTKEY;
         }
         if ($property === self::PARAM_CATEGORY) {
             $property = DIProperty::TYPE_CATEGORY;
         }
         foreach ($values as $value) {
             $dataValue = $this->dataValueFactory->newPropertyValue($property, $value, false, $subject);
             $this->subobject->addDataValue($dataValue);
         }
     }
     return true;
 }
 protected function addDataValuesToSubobject(ArrayFormatter $parameters)
 {
     $subject = $this->parserData->getSemanticData()->getSubject();
     $this->subobject->setEmptyContainerForId($this->createSubobjectId($parameters));
     foreach ($this->transformParametersToArray($parameters) as $property => $values) {
         if ($property === self::PARAM_SORTKEY) {
             $property = DIProperty::TYPE_SORTKEY;
         }
         foreach ($values as $value) {
             $dataValue = $this->dataValueFactory->newPropertyValue($property, $value, false, $subject);
             $this->subobject->addDataValue($dataValue);
         }
     }
 }
Esempio n. 3
0
 /**
  * Adds property values to the ParserOutput instance
  *
  * @since 1.9
  *
  * @param array $properties
  *
  * @return string
  */
 protected function addPropertyValue(array $properties, $value, $valueCaption)
 {
     $subject = $this->parserData->getSemanticData()->getSubject();
     // Add properties to the semantic container
     foreach ($properties as $property) {
         $dataValue = $this->dataValueFactory->newPropertyValue($property, $value, $valueCaption, $subject);
         if ($this->isEnabledNamespace && $this->isAnnotation) {
             $this->parserData->addDataValue($dataValue);
         }
     }
     // Return the text representation
     $result = $dataValue->getShortWikitext(true);
     // If necessary add an error text
     if ($this->settings->get('smwgInlineErrors') && $this->isEnabledNamespace && $this->isAnnotation && !$dataValue->isValid()) {
         $result .= $dataValue->getErrorText();
     }
     return $result;
 }
 /**
  * Adds property values to the ParserOutput instance
  *
  * @since 1.9
  *
  * @param array $properties
  *
  * @return string
  */
 protected function addPropertyValue(array $properties, $value, $valueCaption)
 {
     $subject = $this->parserData->getSubject();
     // Add properties to the semantic container
     foreach ($properties as $property) {
         $dataValue = $this->dataValueFactory->newPropertyValue($property, $value, $valueCaption, $subject);
         if ($this->isEnabledNamespace && $this->isAnnotation) {
             $this->parserData->addDataValue($dataValue);
         }
     }
     // Return the text representation
     $result = $dataValue->getShortWikitext(true);
     // If necessary add an error text
     if ($this->settings->get('smwgInlineErrors') && $this->isEnabledNamespace && $this->isAnnotation && !$dataValue->isValid()) {
         // Encode `:` to avoid a comment block and instead of the nowiki tag
         // use : as placeholder
         $result = str_replace(':', ':', $result) . $dataValue->getErrorText();
     }
     return $result;
 }