本文整理汇总了PHP中SMWDataItem::getDIType方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDataItem::getDIType方法的具体用法?PHP SMWDataItem::getDIType怎么用?PHP SMWDataItem::getDIType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDataItem
的用法示例。
在下文中一共展示了SMWDataItem::getDIType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSerialization
/**
* Get the serialization for the provided data item.
*
* @since 1.7
*
* @param SMWDataItem $dataItem
*
* @return mixed
*/
public static function getSerialization(DataItem $dataItem, $printRequest = null)
{
$result = array();
switch ($dataItem->getDIType()) {
case DataItem::TYPE_WIKIPAGE:
$title = $dataItem->getTitle();
$result = array('fulltext' => $title->getFullText(), 'fullurl' => $title->getFullUrl(), 'namespace' => $title->getNamespace(), 'exists' => $title->isKnown());
break;
case DataItem::TYPE_NUMBER:
// dataitems and datavalues
// Quantity is a datavalue type that belongs to dataitem
// type number which means in order to identify the correct
// unit, we have re-factor the corresponding datavalue otherwise
// we will not be able to determine the unit
// (unit is part of the datavalue object)
if ($printRequest !== null && $printRequest->getTypeID() === '_qty') {
$diProperty = $printRequest->getData()->getDataItem();
$dataValue = DataValueFactory::getInstance()->newDataItemValue($dataItem, $diProperty);
$result = array('value' => $dataValue->getNumber(), 'unit' => $dataValue->getUnit());
} else {
$result = $dataItem->getNumber();
}
break;
case DataItem::TYPE_GEO:
$result = $dataItem->getCoordinateSet();
break;
case DataItem::TYPE_TIME:
$result = $dataItem->getMwTimestamp();
break;
default:
$result = $dataItem->getSerialization();
break;
}
return $result;
}
示例2: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_BOOLEAN) {
return false;
}
return $di->getBoolean() === $this->m_boolean;
}
示例3: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_ERROR) {
return false;
}
return $di->getSerialization() === $this->getSerialization();
}
示例4: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_NUMBER) {
return false;
}
return $di->getNumber() === $this->m_number;
}
示例5: loadDataItem
/**
* @see DataValue::loadDataItem
*
* @param DataItem $dataItem
*
* @return boolean
*/
protected function loadDataItem(DataItem $dataItem)
{
if ($dataItem->getDIType() !== DataItem::TYPE_BOOLEAN) {
return false;
}
$this->m_dataitem = $dataItem;
$this->m_caption = $this->getStandardCaption(true);
return true;
}
示例6: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem( SMWDataItem $dataItem ) {
if ( $dataItem->getDIType() == SMWDataItem::TYPE_CONCEPT ) {
$this->m_dataitem = $dataItem;
$this->m_caption = $dataItem->getConceptQuery(); // probably useless
return true;
} else {
return false;
}
}
示例7: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_ERROR) {
$this->addError($dataItem->getErrors());
$this->m_caption = $this->getErrorText();
return true;
} else {
return false;
}
}
示例8: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_BOOLEAN) {
$this->m_dataitem = $dataItem;
$this->m_caption = $this->getStandardCaption(true);
// use default for this language
return true;
} else {
return false;
}
}
示例9: loadDataItem
/**
* @see SMWDataValue::setDataItem()
*
* @since 1.0
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_GEO) {
$this->m_dataitem = $dataItem;
global $smgQPCoodFormat, $smgQPCoodDirectional;
$this->wikiValue = MapsCoordinateParser::formatCoordinates($dataItem->getCoordinateSet(), $smgQPCoodFormat, $smgQPCoodDirectional);
return true;
} else {
return false;
}
}
示例10: getSerialization
/**
* Get the serialization for the provided data item.
*
* @since 1.7
*
* @param SMWDataItem $dataItem
*
* @return mixed
*/
public static function getSerialization(DataItem $dataItem, $printRequest = null)
{
switch ($dataItem->getDIType()) {
case DataItem::TYPE_WIKIPAGE:
// Support for a deserializable _rec type with 0.6
if ($printRequest !== null && strpos($printRequest->getTypeID(), '_rec') !== false) {
$recordValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $printRequest->getData()->getDataItem());
$recordDiValues = array();
foreach ($recordValue->getPropertyDataItems() as $property) {
$label = $property->getLabel();
$recordDiValues[$label] = array('label' => $label, 'key' => $property->getKey(), 'typeid' => $property->findPropertyTypeID(), 'item' => array());
foreach ($recordValue->getDataItem()->getSemanticData()->getPropertyValues($property) as $value) {
$recordDiValues[$label]['item'][] = self::getSerialization($value);
}
}
$result = $recordDiValues;
} else {
$title = $dataItem->getTitle();
$wikiPageValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem);
$result = array('fulltext' => $title->getFullText(), 'fullurl' => $title->getFullUrl(), 'namespace' => $title->getNamespace(), 'exists' => strval($title->isKnown()), 'displaytitle' => $wikiPageValue->getDisplayTitle());
}
break;
case DataItem::TYPE_NUMBER:
// dataitems and datavalues
// Quantity is a datavalue type that belongs to dataitem
// type number which means in order to identify the correct
// unit, we have re-factor the corresponding datavalue otherwise
// we will not be able to determine the unit
// (unit is part of the datavalue object)
if ($printRequest !== null && $printRequest->getTypeID() === '_qty') {
$diProperty = $printRequest->getData()->getDataItem();
$dataValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $diProperty);
$result = array('value' => $dataValue->getNumber(), 'unit' => $dataValue->getUnit());
} else {
$result = $dataItem->getNumber();
}
break;
case DataItem::TYPE_GEO:
$result = $dataItem->getCoordinateSet();
break;
case DataItem::TYPE_TIME:
$result = array('timestamp' => $dataItem->getMwTimestamp(), 'raw' => $dataItem->getSerialization());
break;
default:
$result = $dataItem->getSerialization();
break;
}
return $result;
}
示例11: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
$diType = $this->m_typeid == '_txt' || $this->m_typeid == '_cod' ? SMWDataItem::TYPE_BLOB : SMWDataItem::TYPE_STRING;
if ($dataItem->getDIType() == $diType) {
$this->m_dataitem = $dataItem;
if ($this->m_typeid == '_cod') {
$this->m_caption = $this->getCodeDisplay($this->m_dataitem->getString());
} else {
$this->m_caption = $this->m_dataitem->getString();
}
return true;
} else {
return false;
}
}
示例12: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_STRING) {
$this->m_dataitem = $dataItem;
$this->m_diProperties = array();
foreach (explode(';', $dataItem->getString()) as $propertyKey) {
try {
$this->m_diProperties[] = new SMWDIProperty($propertyKey);
} catch (SMWDataItemException $e) {
$this->m_diProperties[] = new SMWDIProperty('Error');
$this->addError(wfMsgForContent('smw_parseerror'));
}
}
$this->m_caption = false;
return true;
} else {
return false;
}
}
示例13: getSerialization
/**
* Get the serialization for the provided data item.
*
* @since 1.7
*
* @param SMWDataItem $dataItem
*
* @return mixed
*/
public static function getSerialization(SMWDataItem $dataItem)
{
switch ($dataItem->getDIType()) {
case SMWDataItem::TYPE_WIKIPAGE:
$title = $dataItem->getTitle();
$result = array('fulltext' => $title->getFullText(), 'fullurl' => $title->getFullUrl());
break;
case SMWDataItem::TYPE_NUMBER:
$result = $dataItem->getNumber();
break;
case SMWDataItem::TYPE_GEO:
$result = $dataItem->getCoordinateSet();
break;
case SMWDataItem::TYPE_TIME:
$result = $dataItem->getMwTimestamp();
break;
default:
$result = $dataItem->getSerialization();
break;
}
return $result;
}
示例14: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_CONTAINER) {
$this->m_dataitem = $dataItem;
return true;
} elseif ($dataItem->getDIType() == SMWDataItem::TYPE_WIKIPAGE) {
$semanticData = new SMWContainerSemanticData($dataItem);
$semanticData->copyDataFrom(\SMW\StoreFactory::getStore()->getSemanticData($dataItem));
$this->m_dataitem = new SMWDIContainer($semanticData);
return true;
} else {
return false;
}
}
示例15: getDataItemHelperExpElement
/**
* Create an SWMExpElement that encodes auxiliary data for representing
* values of the specified dataitem object in a simplified fashion.
* This is done for types of dataitems that are not supported very well
* in current systems, or that do not match a standard datatype in RDF.
* For example, time points (DITime) are encoded as numbers. The number
* can replace the actual time for all query and ordering purposes (the
* order in either case is linear and maps to the real number line).
* Only data retrieval should better use the real values to avoid that
* rounding errors lead to unfaithful recovery of data. Note that the
* helper values do not maintain any association with their original
* values -- they are a fully redundant alternative representation, not
* an additional piece of information for the main values. Even if
* decoding is difficult, they must be in one-to-one correspondence to
* the original value.
*
* For dataitems that do not have such a simplification, the method
* returns null.
*
* @note If a helper element is used, then it must be the same as
* getDataItemHelperExpElement( $dataItem->getSortKeyDataItem() ).
* Query conditions like ">" use sortkeys for values, and helper
* elements are always preferred in query answering.
*
* @param $dataItem SMWDataItem
* @return SMWExpElement or null
*/
public static function getDataItemHelperExpElement(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_TIME) {
$lit = new SMWExpLiteral($dataItem->getSortKey(), 'http://www.w3.org/2001/XMLSchema#double', $dataItem);
return $lit;
} else {
return null;
}
}