/**
  * @since 1.8
  *
  * {@inheritDoc}
  */
 public function dataItemFromDBKeys($dbkeys)
 {
     if (is_string($dbkeys)) {
         return DINumber::doUnserialize($dbkeys);
     }
     throw new DataItemHandlerException('Failed to create data item from DB keys.');
 }
 /**
  * @see SMWDataItemHandler::dataItemFromDBKeys()
  * @since 1.8
  * @param array|string $dbkeys expecting string here
  *
  * @return SMWDataItem
  */
 public function dataItemFromDBKeys($dbkeys)
 {
     if (is_string($dbkeys)) {
         return SMWDINumber::doUnserialize($dbkeys);
     } else {
         throw new SMWDataItemException('Failed to create data item from DB keys.');
     }
 }
 /**
  * Method to create a dataitem from a type ID and array of DB keys.
  * Throws SMWDataItemException if problems occur, to get our callers
  * used to it.
  *
  * @param $typeid string id for the given type
  * @param $dbkeys array of mixed
  *
  * @return SMWDataItem
  */
 public static function dataItemFromDBKeys($typeid, $dbkeys)
 {
     switch (SMWDataValueFactory::getDataItemId($typeid)) {
         case SMWDataItem::TYPE_ERROR:
         case SMWDataItem::TYPE_NOTYPE:
             break;
         case SMWDataItem::TYPE_NUMBER:
             return SMWDINumber::doUnserialize($dbkeys[0]);
         case SMWDataItem::TYPE_STRING:
             return new SMWDIString($dbkeys[0]);
         case SMWDataItem::TYPE_BLOB:
             return new SMWDIBlob($dbkeys[0]);
         case SMWDataItem::TYPE_BOOLEAN:
             return new SMWDIBoolean($dbkeys[0] == '1');
         case SMWDataItem::TYPE_URI:
             if ($typeid == '__typ' && $dbkeys[0][0] == '_') {
                 // b/c: old data stored as type ids
                 return SMWTypesValue::getTypeUriFromTypeId($dbkeys[0]);
             } else {
                 return SMWDIUri::doUnserialize($dbkeys[0]);
             }
         case SMWDataItem::TYPE_TIME:
             $timedate = explode('T', $dbkeys[0], 2);
             if (count($dbkeys) == 2 && count($timedate) == 2) {
                 $date = reset($timedate);
                 $year = $month = $day = $hours = $minutes = $seconds = $timeoffset = false;
                 if (end($timedate) === '' || SMWTimeValue::parseTimeString(end($timedate), $hours, $minutes, $seconds, $timeoffset) == true) {
                     $d = explode('/', $date, 3);
                     if (count($d) == 3) {
                         list($year, $month, $day) = $d;
                     } elseif (count($d) == 2) {
                         list($year, $month) = $d;
                     } elseif (count($d) == 1) {
                         list($year) = $d;
                     }
                     if ($month === '') {
                         $month = false;
                     }
                     if ($day === '') {
                         $day = false;
                     }
                     $calendarmodel = SMWDITime::CM_GREGORIAN;
                     return new SMWDITime($calendarmodel, $year, $month, $day, $hours, $minutes, $seconds);
                 }
             }
             break;
         case SMWDataItem::TYPE_GEO:
             return new SMWDIGeoCoord(array('lat' => (double) $dbkeys[0], 'lon' => (double) $dbkeys[1]));
         case SMWDataItem::TYPE_CONTAINER:
             // provided for backwards compatibility only;
             // today containers are read from the store as substructures,
             // not retrieved as single complex values
             $semanticData = SMWContainerSemanticData::makeAnonymousContainer();
             foreach (reset($dbkeys) as $value) {
                 if (is_array($value) && count($value) == 2) {
                     $diP = new SMWDIProperty(reset($value), false);
                     $diV = self::dataItemFromDBKeys($diP->findPropertyTypeID(), end($value));
                     $semanticData->addPropertyObjectValue($diP, $diV);
                 }
             }
             return new SMWDIContainer($semanticData);
         case SMWDataItem::TYPE_WIKIPAGE:
             if ($typeid == '__spf') {
                 $pagedbkey = str_replace(' ', '_', $dbkeys[0]);
                 return new SMWDIWikiPage($pagedbkey, SF_NS_FORM, '');
             } elseif (count($dbkeys) >= 5) {
                 // with subobject name (and sortkey)
                 return new SMWDIWikiPage($dbkeys[0], intval($dbkeys[1]), $dbkeys[2], $dbkeys[4]);
             } elseif (count($dbkeys) >= 3) {
                 // without subobject name (just for b/c)
                 return new SMWDIWikiPage($dbkeys[0], intval($dbkeys[1]), $dbkeys[2]);
             }
             break;
         case SMWDataItem::TYPE_CONCEPT:
             if (count($dbkeys) >= 5) {
                 return new SMWDIConcept($dbkeys[0], smwfXMLContentEncode($dbkeys[1]), $dbkeys[2], $dbkeys[3], $dbkeys[4]);
             }
             break;
         case SMWDataItem::TYPE_PROPERTY:
             return new SMWDIProperty($dbkeys[0], false);
     }
     throw new SMWDataItemException('Failed to create data item from DB keys.');
 }
 /**
  * @see SMWDataItemHandler::dataItemFromDBKeys
  * @param $dbkeys array of mixed
  *
  * @return SMWDataItem
  */
 public function dataItemFromDBKeys($dbkeys)
 {
     return SMWDINumber::doUnserialize($dbkeys[0]);
 }