Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @throws SMWStringLengthException if the string is longer than
  * SMWDIString::MAXLENGTH. The bytes are counted, not the (possibly
  * multibyte) glyphs of UTF-8, since we care about byte length in (any)
  * storage backend.
  */
 public function __construct($string)
 {
     if (strlen($string) > SMWDIString::MAXLENGTH) {
         throw new SMWStringLengthException($string, SMWDIString::MAXLENGTH);
     }
     parent::__construct($string);
 }
 private function parseToStringValue(DIBlob $dataItem)
 {
     $this->xsdValue = smwfHTMLtoUTF8($dataItem->getString());
     $this->xsdType = 'http://www.w3.org/2001/XMLSchema#string';
 }
 /**
  * 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;
 }
 /**
  * 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;
 }