/**
  * @param Parser $parser
  * @param ProcessingResult $result
  *
  * @return mixed
  */
 public function handle(Parser $parser, ProcessingResult $result)
 {
     if ($result->hasFatal()) {
         return $this->getOutputForErrors($result->getErrors());
     }
     $parameters = $result->getParameters();
     $this->language = $parameters['language']->getValue();
     $params = $this->getFormatParameters($parameters['format']->getValue());
     if ($parameters['parameters']->getValue() === 'specific') {
         foreach (array_keys(SMWQueryProcessor::getParameters()) as $name) {
             unset($params[$name]);
         }
     } elseif ($parameters['parameters']->getValue() === 'base') {
         foreach (array_diff_key($params, SMWQueryProcessor::getParameters()) as $param) {
             unset($params[$param->getName()]);
         }
     }
     $docBuilder = new ParameterListDocBuilder($this->newMessageFunction());
     return $docBuilder->getParameterTable($params);
 }
 /**
  * @param Parser $parser
  * @param ProcessingResult $result
  *
  * @return mixed
  */
 public function handle(Parser $parser, ProcessingResult $result)
 {
     if ($result->hasFatal()) {
         return $this->getOutputForErrors($result->getErrors());
     }
     $parameters = $result->getParameters();
     if (!isset($parameters['message']) || $parameters['message']->getValue() === '') {
         return '';
     }
     /**
      * Non-escaping is safe bacause a user's message is passed through parser, which will
      * handle unsafe HTM elements.
      */
     $result = smwfEncodeMessages(array($parameters['message']->getValue()), $parameters['icon']->getValue(), ' <!--br-->', false);
     if (!is_null($parser->getTitle()) && $parser->getTitle()->isSpecialPage()) {
         global $wgOut;
         SMWOutputs::commitToOutputPage($wgOut);
     } else {
         SMWOutputs::commitToParser($parser);
     }
     return $result;
 }
 public function testGetErrors()
 {
     $errors = array($this->newMockError());
     $result = new ProcessingResult(array(), $errors);
     $this->assertEquals($errors, $result->getErrors());
 }