/** * 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); }
/** * {{#ask}} is disabled (see $smwgQEnabled) * * @since 1.9 * * @return string|null */ public function isQueryDisabled() { return $this->messageFormatter->addFromKey('smw_iq_disabled')->getHtml(); }