private function getResultContent(DataItem $dataItem)
 {
     $dataValue = $this->printRequest->getData();
     $dataItems = array($dataItem);
     if (!$dataValue->isValid()) {
         return array();
     }
     // If it is a chain then try to find a connected DIWikiPage subject that
     // matches the property on the chained PrintRequest.
     // For example, Number.Date.SomeThing will not return any meaningful results
     // because Number will return a DINumber object and not a DIWikiPage.
     // If on the other hand Has page.Number (with Number being the Last and
     // `Has page` is of type Page) then the iteration will lookup on results
     // for `Has page` and try to match a Number annotation on the results
     // retrieved from `Has page`.
     if ($this->printRequest->isMode(PrintRequest::PRINT_CHAIN)) {
         // Output of the previous iteration is the input for the next iteration
         foreach ($dataValue->getPropertyChainValues() as $pv) {
             $dataItems = $this->doFetchPropertyValues($dataItems, $pv);
             // If the results return empty then it means that for this element
             // the chain has no matchable items hence we stop
             if ($dataItems === array()) {
                 return array();
             }
         }
         $dataValue = $dataValue->getLastPropertyChainValue();
     }
     return $this->doFetchPropertyValues($dataItems, $dataValue);
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }