Example #1
0
 private function setFields(ProcessingResult $result)
 {
     $params = $result->getParameters();
     $this->fileName = $params['file']->getValue();
     $this->repoName = $params['repo']->getValue();
     $this->branchName = $params['branch']->getValue();
 }
Example #2
0
 private function getSubPageCount(Parser $parser, ProcessingResult $result)
 {
     $parameters = $result->getParameters();
     $title = $this->getTitle($parser, $parameters['page']->getValue());
     if ($title === null) {
         return 0;
     }
     return $this->counter->countSubPages($title);
 }
Example #3
0
 /**
  * @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...)
 }
Example #4
0
 /**
  * @param Parser $parser
  * @param ProcessingResult $result
  *
  * @return mixed
  */
 public function handle(Parser $parser, ProcessingResult $result)
 {
     $parameters = $result->getParameters();
     /**
      * 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;
 }
 /**
  * @param Parser $parser
  * @param ProcessingResult $result
  *
  * @return mixed
  */
 public function handle(Parser $parser, ProcessingResult $result)
 {
     $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()]);
         }
     }
     return $this->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();
     $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);
 }
 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());
 }