コード例 #1
0
 /**
  * Method to return an array of fields=>values for a DataItem
  * This array is used to perform all insert operations into the DB
  * To optimize return minimum fields having indexes
  *
  * @since 1.8
  *
  * @param SMWDataItem $dataItem
  *
  * @return array
  */
 public function getInsertValues(SMWDataItem $dataItem)
 {
     return array('concept_txt' => $dataItem->getConceptQuery(), 'concept_docu' => $dataItem->getDocumentation(), 'concept_features' => $dataItem->getQueryFeatures(), 'concept_size' => $dataItem->getSize(), 'concept_depth' => $dataItem->getDepth());
 }
コード例 #2
0
 /**
  * Compatibility function for computing the old getDBkeys() array for
  * the new SMW data items.
  *
  * @param $dataItem SMWDataItem
  * @return array of mixed
  */
 public static function getDBkeysFromDataItem(SMWDataItem $dataItem)
 {
     switch ($dataItem->getDIType()) {
         case SMWDataItem::TYPE_STRING:
         case SMWDataItem::TYPE_BLOB:
             return array($dataItem->getString());
         case SMWDataItem::TYPE_URI:
             return array($dataItem->getSerialization());
         case SMWDataItem::TYPE_WIKIPAGE:
             return array($dataItem->getDBkey(), $dataItem->getNamespace(), $dataItem->getInterwiki(), $dataItem->getSortKey());
         case SMWDataItem::TYPE_NUMBER:
             return array($dataItem->getSerialization(), floatval($dataItem->getNumber()));
         case SMWDataItem::TYPE_TIME:
             $xsdvalue = $dataItem->getYear() . "/" . ($dataItem->getPrecision() >= SMWDITime::PREC_YM ? $dataItem->getMonth() : '') . "/" . ($dataItem->getPrecision() >= SMWDITime::PREC_YMD ? $dataItem->getDay() : '') . "T";
             if ($dataItem->getPrecision() == SMWDITime::PREC_YMDT) {
                 $xsdvalue .= sprintf("%02d", $dataItem->getHour()) . ':' . sprintf("%02d", $dataItem->getMinute()) . ':' . sprintf("%02d", $dataItem->getSecond());
             }
             return array($xsdvalue, $dataItem->getSortKey());
         case SMWDataItem::TYPE_BOOLEAN:
             return $dataItem->getBoolean() ? array('1', 1) : array('0', 0);
         case SMWDataItem::TYPE_CONTAINER:
             return array(false);
         case SMWDataItem::TYPE_CONCEPT:
             return array($dataItem->getConceptQuery(), $dataItem->getDocumentation(), $dataItem->getQueryFeatures(), $dataItem->getSize(), $dataItem->getDepth());
         case SMWDataItem::TYPE_PROPERTY:
             return array($dataItem->getKey());
         case SMWDataItem::TYPE_GEO:
             $coordinateSet = $dataItem->getCoordinateSet();
             return array($coordinateSet['lat'], $coordinateSet['lon']);
         default:
             return array(false);
     }
 }