/** * @since 1.9 * * @param ArrayFormatter $params * * @return string|null */ public function parse(ArrayFormatter $parameters) { $this->addDataValuesToSubobject($parameters); $this->parserData->getSemanticData()->addSubobject($this->subobject); $this->parserData->pushSemanticDataToParserOutput(); return $this->messageFormatter->addFromArray($this->subobject->getErrors())->addFromArray($this->parserData->getErrors())->addFromArray($parameters->getErrors())->getHtml(); }
/** * Parse parameters, return concept information box and update the * ParserOutput with the concept object * * @since 1.9 * * @param array $params * * @return string|null */ public function parse(array $rawParams) { $this->parserData->getOutput()->addModules('ext.smw.style'); $title = $this->parserData->getTitle(); $property = new DIProperty('_CONC'); if (!($title->getNamespace() === SMW_NS_CONCEPT)) { return $this->messageFormatter->addFromKey('smw_no_concept_namespace')->getHtml(); } elseif (count($this->parserData->getSemanticData()->getPropertyValues($property)) > 0) { return $this->messageFormatter->addFromKey('smw_multiple_concepts')->getHtml(); } // Remove parser object from parameters array if (isset($rawParams[0]) && $rawParams[0] instanceof Parser) { array_shift($rawParams); } // Use first parameter as concept (query) string $conceptQuery = array_shift($rawParams); // Use second parameter, if any as a description $conceptDocu = array_shift($rawParams); $query = $this->buildQuery($conceptQuery); $conceptQueryString = $query->getDescription()->getQueryString(); $this->parserData->getSemanticData()->addPropertyObjectValue($property, new DIConcept($conceptQueryString, $conceptDocu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth())); $this->messageFormatter->addFromArray($query->getErrors())->addFromArray($this->parserData->getErrors()); $this->addQueryProfile($query); $this->parserData->pushSemanticDataToParserOutput(); if ($this->messageFormatter->exists()) { return $this->messageFormatter->getHtml(); } return $this->buildConceptInfoBox($title, $conceptQueryString, $conceptDocu); }
/** * @since 1.9 * * @param ParserParameterProcessor $params * * @return string|null */ public function parse(ParserParameterProcessor $parameters) { if ($this->parserData->canModifySemanticData() && $this->addDataValuesToSubobject($parameters) && !$this->subobject->getSemanticData()->isEmpty()) { $this->parserData->getSemanticData()->addSubobject($this->subobject); } $this->parserData->pushSemanticDataToParserOutput(); $html = $this->messageFormatter->addFromArray($this->subobject->getErrors())->addFromArray($this->parserData->getErrors())->addFromArray($parameters->getErrors())->getHtml(); // An empty output in MW forces an extra <br> element. //if ( $html == '' ) { // $html = '<p></p>'; //} return $html; }
/** * @dataProvider getPropertyValueDataProvider */ public function testAddDataValue($propertyName, $value, $errorCount, $propertyCount) { $title = Title::newFromText(__METHOD__); $parserOutput = new ParserOutput(); $instance = new ParserData($title, $parserOutput); $instance->addDataValue($this->dataValueFactory->newPropertyValue($propertyName, $value)); if ($errorCount > 0) { return $this->assertCount($errorCount, $instance->getErrors()); } $expected = array('propertyCount' => $propertyCount, 'propertyLabels' => $propertyName, 'propertyValues' => $value); $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getSemanticData()); }