本文整理汇总了PHP中SMWDataItem类的典型用法代码示例。如果您正苦于以下问题:PHP SMWDataItem类的具体用法?PHP SMWDataItem怎么用?PHP SMWDataItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMWDataItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: equals
public function equals(SMWDataItem $di)
{
if (!$di instanceof SMWDIBlob) {
return false;
}
return $di->getString() === $this->m_string;
}
示例2: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_NUMBER) {
return false;
}
return $di->getNumber() === $this->m_number;
}
示例3: 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;
}
示例4: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_ERROR) {
return false;
}
return $di->getSerialization() === $this->getSerialization();
}
示例5: equals
public function equals(SMWDataItem $di)
{
if ($di->getDIType() !== SMWDataItem::TYPE_BOOLEAN) {
return false;
}
return $di->getBoolean() === $this->m_boolean;
}
示例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::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;
}
}
示例9: 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;
}
}
示例10: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem instanceof SMWDIUri && $dataItem->getScheme() == 'http' && $dataItem->getHierpart() == 'semantic-mediawiki.org/swivt/1.0' && $dataItem->getQuery() === '') {
$this->m_isAlias = false;
$this->m_typeId = $dataItem->getFragment();
$this->m_realLabel = SMWDataValueFactory::findTypeLabel($this->m_typeId);
$this->m_caption = $this->m_givenLabel = $this->m_realLabel;
$this->m_dataitem = $dataItem;
return true;
} else {
return false;
}
}
示例11: 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;
}
示例12: 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;
}
}
示例13: newFromSerialization
/**
* Creates and returns a new SWLPropertyChange instance from a serialization.
*
* @param string|null $oldValue
* @param string|null $newValue
*
* @return SWLPropertyChange
*/
public static function newFromSerialization(SMWDIProperty $property, $oldValue, $newValue)
{
$diType = SMWDataValueFactory::getDataItemId($property->findPropertyTypeID());
//var_dump($property);
//if($diType!=7) {throw new Exception();exit;}
return new self(is_null($oldValue) ? null : SMWDataItem::newFromSerialization($diType, $oldValue), is_null($newValue) ? null : SMWDataItem::newFromSerialization($diType, $newValue));
}
示例14: newFromSerialization
/**
* Creates and returns a new SWLPropertyChange instance from a serialization.
*
* @param string|null $oldValue
* @param string|null $newValue
*
* @return SWLPropertyChange
*/
public static function newFromSerialization( SMWDIProperty $property, $oldValue, $newValue ) {
$diType = SMWDataValueFactory::getDataItemId( $property->findPropertyTypeID() );
return new self(
is_null( $oldValue ) ? null : SMWDataItem::newFromSerialization( $diType, $oldValue ),
is_null( $newValue ) ? null : SMWDataItem::newFromSerialization( $diType, $newValue )
);
}
示例15: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem instanceof SMWDIBlob) {
$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(wfMessage('smw_parseerror')->inContentLanguage()->text());
}
}
$this->m_caption = false;
return true;
} else {
return false;
}
}