/** * @dataProvider stripTextWithAnnotationProvider */ public function testStrip($text, $expectedRemoval, $expectedObscuration) { $this->assertEquals($expectedRemoval, InTextAnnotationParser::removeAnnotation($text)); $this->assertEquals($expectedObscuration, InTextAnnotationParser::obscureAnnotation($text)); }
/** * Return an SMWDataValue object for the next SMWDataItem object or * false if no further object exists. * * @since 1.6 * * @return SMWDataValue|false */ public function getNextDataValue() { $dataItem = $this->getNextDataItem(); if ($dataItem === false) { return false; } if ($this->mPrintRequest->getMode() == PrintRequest::PRINT_PROP && strpos($this->mPrintRequest->getTypeID(), '_rec') !== false && $this->mPrintRequest->getParameter('index') !== false) { $recordValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $this->mPrintRequest->getData()->getDataItem()); $diProperty = $recordValue->getPropertyDataItemByIndex($this->mPrintRequest->getParameter('index')); } elseif ($this->mPrintRequest->isMode(PrintRequest::PRINT_PROP)) { $diProperty = $this->mPrintRequest->getData()->getDataItem(); } elseif ($this->mPrintRequest->isMode(PrintRequest::PRINT_CHAIN)) { $diProperty = $this->mPrintRequest->getData()->getLastPropertyChainValue()->getDataItem(); } else { $diProperty = null; } // refs #1314 if ($this->mPrintRequest->getMode() == PrintRequest::PRINT_PROP && strpos($this->mPrintRequest->getTypeID(), '_txt') !== false && $dataItem instanceof DIBlob) { $dataItem = new DIBlob(InTextAnnotationParser::removeAnnotation($dataItem->getString())); } $dataValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $diProperty); $dataValue->setContextPage($this->mResult); if ($this->mPrintRequest->getOutputFormat()) { $dataValue->setOutputFormat($this->mPrintRequest->getOutputFormat()); } if ($this->entityListAccumulator !== null && $dataItem instanceof DataItem) { $this->entityListAccumulator->addToEntityList($dataItem, $diProperty); } return $dataValue; }
/** * Return an SMWDataValue object for the next SMWDataItem object or * false if no further object exists. * * @since 1.6 * * @return SMWDataValue|false */ public function getNextDataValue() { $di = $this->getNextDataItem(); if ($di === false) { return false; } if ($this->mPrintRequest->getMode() == PrintRequest::PRINT_PROP && strpos($this->mPrintRequest->getTypeID(), '_rec') !== false && $this->mPrintRequest->getParameter('index') !== false) { // Not efficient, but correct: we need to find the right property for // the selected index of the record here. $pos = $this->mPrintRequest->getParameter('index') - 1; $recordValue = \SMW\DataValueFactory::getInstance()->newDataItemValue($di, $this->mPrintRequest->getData()->getDataItem()); $diProperties = $recordValue->getPropertyDataItems(); if (array_key_exists($pos, $diProperties) && !is_null($diProperties[$pos])) { $diProperty = $diProperties[$pos]; } else { $diProperty = null; } } elseif ($this->mPrintRequest->getMode() == PrintRequest::PRINT_PROP) { $diProperty = $this->mPrintRequest->getData()->getDataItem(); } else { $diProperty = null; } // refs #1314 if ($this->mPrintRequest->getMode() == PrintRequest::PRINT_PROP && strpos($this->mPrintRequest->getTypeID(), '_txt') !== false) { $di = new DIBlob(InTextAnnotationParser::removeAnnotation($di->getString())); } $dv = \SMW\DataValueFactory::getInstance()->newDataItemValue($di, $diProperty); if ($this->mPrintRequest->getOutputFormat()) { $dv->setOutputFormat($this->mPrintRequest->getOutputFormat()); } return $dv; }
/** * Processing and reparsing of the Factbox content */ private function rebuild(Title $title, ParserOutput $parserOutput, $requestContext) { $text = null; $applicationFactory = ApplicationFactory::getInstance(); $factbox = $applicationFactory->newFactboxFactory()->newFactbox($applicationFactory->newParserData($title, $parserOutput), $requestContext); $factbox->useInPreview($requestContext->getRequest()->getCheck('wpPreview')); if ($factbox->doBuild()->isVisible()) { $contentParser = $applicationFactory->newContentParser($title); $contentParser->parse($factbox->getContent()); $text = InTextAnnotationParser::removeAnnotation($contentParser->getOutput()->getText()); } return $text; }