/** * @see HookHandler::handle * * @since 1.0 * * @param Parser $parser * @param ProcessingResult $result * * @return string */ public function handle(Parser $parser, ProcessingResult $result) { if ($result->hasFatal()) { // TODO: return 'Invalid input. Cannot calculate sub page count.'; } $count = $this->getSubPageCount($parser, $result); return $parser->getTargetLanguage()->formatNum($count); }
/** * @see HookHandler::handle * * @since 1.2 * * @param Parser $parser * @param ProcessingResult $result * * @return string */ public function handle(Parser $parser, ProcessingResult $result) { if ($result->hasFatal()) { // This should not occur given the current parameter definitions. return 'Error: invalid input into subPageList function'; } $parameters = $this->paramsToOptions($result->getParameters()); $title = $this->getTitle($parser, $parameters['page']); if ($title !== null) { return $this->renderForTitle($title, $parameters); } return 'Error: invalid title provided'; // TODO (might want to use a title param...) }
/** * @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 testGivenFatalError_HasFatal() { $result = new ProcessingResult(array(), array(new ProcessingError('', ProcessingError::SEVERITY_HIGH), new ProcessingError('', ProcessingError::SEVERITY_LOW), new ProcessingError('', ProcessingError::SEVERITY_FATAL), new ProcessingError('', ProcessingError::SEVERITY_MINOR), new ProcessingError('', ProcessingError::SEVERITY_NORMAL))); $this->assertTrue($result->hasFatal()); }