本文整理汇总了PHP中SMWDataItem::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDataItem::getTitle方法的具体用法?PHP SMWDataItem::getTitle怎么用?PHP SMWDataItem::getTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDataItem
的用法示例。
在下文中一共展示了SMWDataItem::getTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: tryToFindRedirectVariableForDataItem
/**
* @since 2.3
*
* @param DataItem|null $dataItem
*
* @return string|null
*/
public function tryToFindRedirectVariableForDataItem(DataItem $dataItem = null)
{
if (!$dataItem instanceof DIWikiPage || !$this->canUseQFeature(SMW_SPARQL_QF_REDI)) {
return null;
}
// Maybe there is a better way to verify the "isRedirect" state other
// than by using the Title object
if ($dataItem->getTitle() === null || !$dataItem->getTitle()->isRedirect()) {
return null;
}
$redirectExpElement = Exporter::getInstance()->getResourceElementForWikiPage($dataItem);
$valueName = TurtleSerializer::getTurtleNameForExpElement($redirectExpElement);
// Add unknow redirect target/variable for value
if (!isset($this->redirectByVariableReplacementMap[$valueName])) {
$namespaces[$redirectExpElement->getNamespaceId()] = $redirectExpElement->getNamespace();
$redirectByVariable = '?' . $this->getNextVariable('r');
$this->redirectByVariableReplacementMap[$valueName] = array($redirectByVariable, $namespaces);
}
// Reuse an existing variable for the value to allow to be used more than
// once when referring to the same property/value redirect
list($redirectByVariable, $namespaces) = $this->redirectByVariableReplacementMap[$valueName];
return $redirectByVariable;
}