Exemplo n.º 1
0
 /**
  * @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 $parameters
  *
  * @return string|null
  */
 public function parse(ParserParameterProcessor $parameters)
 {
     $count = 0;
     $template = '';
     $subject = $this->parserData->getSemanticData()->getSubject();
     $parametersToArray = $parameters->toArray();
     if (isset($parametersToArray['template'])) {
         $template = $parametersToArray['template'][0];
         unset($parametersToArray['template']);
     }
     foreach ($parametersToArray as $property => $values) {
         $last = count($values) - 1;
         // -1 because the key starts with 0
         foreach ($values as $key => $value) {
             $dataValue = DataValueFactory::getInstance()->newDataValueByText($property, $value, false, $subject);
             if ($this->parserData->canModifySemanticData()) {
                 $this->parserData->addDataValue($dataValue);
             }
             $this->messageFormatter->addFromArray($dataValue->getErrors());
             $this->addFieldsToTemplate($template, $dataValue, $property, $value, $last == $key, $count);
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     $html = $this->templateRenderer->render() . $this->messageFormatter->addFromArray($parameters->getErrors())->getHtml();
     return array($html, 'noparse' => $template === '', 'isHTML' => false);
 }
Exemplo n.º 4
0
 /**
  * @since  1.9
  *
  * @param ArrayFormatter $parameters
  *
  * @return string|null
  */
 public function parse(ArrayFormatter $parameters)
 {
     $subject = $this->parserData->getSemanticData()->getSubject();
     foreach ($parameters->toArray() as $property => $values) {
         foreach ($values as $value) {
             $dataValue = DataValueFactory::getInstance()->newPropertyValue($property, $value, false, $subject);
             $this->parserData->addDataValue($dataValue);
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     return $this->messageFormatter->addFromArray($this->parserData->getErrors())->addFromArray($parameters->getErrors())->getHtml();
 }
 /**
  * @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;
 }
Exemplo n.º 6
0
 /**
  * @since  1.9
  *
  * @param ArrayFormatter $parameters
  *
  * @return string|null
  */
 public function parse(ArrayFormatter $parameters)
 {
     $count = 0;
     $template = '';
     $subject = $this->parserData->getSemanticData()->getSubject();
     $parametersToArray = $parameters->toArray();
     if (isset($parametersToArray['template'])) {
         $template = $parametersToArray['template'][0];
         unset($parametersToArray['template']);
     }
     foreach ($parametersToArray as $property => $values) {
         foreach ($values as $value) {
             $dataValue = DataValueFactory::getInstance()->newPropertyValue($property, $value, false, $subject);
             $this->parserData->addDataValue($dataValue);
             $this->messageFormatter->addFromArray($dataValue->getErrors());
             $this->addFieldsToTemplate($template, $dataValue, $property, $value, $count);
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     $html = $this->templateRenderer->render() . $this->messageFormatter->addFromArray($parameters->getErrors())->getHtml();
     return array($html, 'noparse' => true, 'isHTML' => true);
 }