private function addProcessingError($errors) { $processingErrorMsgHandler = new ProcessingErrorMsgHandler($this->parserData->getSubject()); foreach ($errors as $error) { $processingErrorMsgHandler->pushTo($this->parserData->getSemanticData(), $processingErrorMsgHandler->getErrorContainerFromMsg($error, new DIProperty('_ASK'))); } }
public function testGetterInstances() { $title = Title::newFromText(__METHOD__); $parserOutput = new ParserOutput(); $instance = new ParserData($title, $parserOutput); $this->assertInstanceOf('Title', $instance->getTitle()); $this->assertInstanceOf('ParserOutput', $instance->getOutput()); $this->assertInstanceOf('\\SMW\\DIWikiPage', $instance->getSubject()); }
private function createQueryProfile($query, $format, $duration) { // In case of an query error add a marker to the subject for // discoverability of a failed query if ($query->getErrors() !== array()) { $error = new Error($this->parserData->getSubject()); $this->parserData->getSemanticData()->addPropertyObjectValue($error->getProperty(), $error->getContainerFor(new DIProperty('_ASK'), $query->getQueryString() . ' (' . implode(' ', $query->getErrors()) . ')')); } $queryProfileAnnotatorFactory = $this->applicationFactory->newQueryProfileAnnotatorFactory(); $jointProfileAnnotator = $queryProfileAnnotatorFactory->newJointProfileAnnotator($query, $format, $duration); $jointProfileAnnotator->addAnnotation(); $this->parserData->getSemanticData()->addPropertyObjectValue($jointProfileAnnotator->getProperty(), $jointProfileAnnotator->getContainer()); }
/** * Returns content found for a given ParserOutput object and if the required * custom data was not available then semantic data are retrieved from * the store for a given subject. * * The method checks whether the given setting of $showfactbox requires * displaying the given data at all. * * @since 1.9 * * @return integer $showFactbox * * @return string|null */ protected function fetchContent($showFactbox = SMW_FACTBOX_NONEMPTY) { if ($showFactbox === SMW_FACTBOX_HIDDEN) { return ''; } $semanticData = $this->parserData->getSemanticData(); if ($semanticData === null || $semanticData->stubObject || $this->isEmpty($semanticData)) { $semanticData = $this->store->getSemanticData($this->parserData->getSubject()); } if ($showFactbox === SMW_FACTBOX_SPECIAL && !$semanticData->hasVisibleSpecialProperties()) { // show only if there are special properties return ''; } elseif ($showFactbox === SMW_FACTBOX_NONEMPTY && !$semanticData->hasVisibleProperties()) { // show only if non-empty return ''; } return $this->createTable($semanticData); }
/** * 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; }