本文整理汇总了PHP中SMWDataItem::getString方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDataItem::getString方法的具体用法?PHP SMWDataItem::getString怎么用?PHP SMWDataItem::getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDataItem
的用法示例。
在下文中一共展示了SMWDataItem::getString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: equals
public function equals(SMWDataItem $di)
{
if (!$di instanceof SMWDIBlob) {
return false;
}
return $di->getString() === $this->m_string;
}
示例2: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem DataItem
* @return boolean
*/
protected function loadDataItem(DataItem $dataItem)
{
if (!$dataItem instanceof DIBlob) {
return false;
}
$this->m_dataitem = $dataItem;
$parts = explode(' ', $dataItem->getString(), 4);
if (count($parts) != 4) {
$this->addErrorMsg(array('smw-datavalue-import-invalid-format', $dataItem->getString()));
} else {
$this->m_namespace = $parts[0];
$this->m_section = $parts[1];
$this->m_uri = $parts[2];
$this->termType = $parts[3];
$this->m_qname = $this->m_namespace . ':' . $this->m_section;
$this->m_caption = "[" . $this->m_uri . " " . $this->m_qname . "] " . " | " . wfMessage('smw-datavalue-import-link', $this->m_namespace)->escaped();
}
return true;
}
示例3: 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;
}
}
示例4: 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;
}
}
示例5: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if (!$dataItem instanceof SMWDIBlob) {
return false;
}
$this->m_dataitem = $dataItem;
$this->m_diProperties = array();
foreach (explode(';', $dataItem->getString()) as $propertyKey) {
$property = null;
try {
$property = new SMWDIProperty($propertyKey);
} catch (SMWDataItemException $e) {
$property = new SMWDIProperty('Error');
$this->addError(wfMessage('smw_parseerror')->inContentLanguage()->text());
}
if ($property instanceof SMWDIProperty) {
// Find a possible redirect
$this->m_diProperties[] = StoreFactory::getStore()->getRedirectTarget($property);
}
}
$this->m_caption = false;
return true;
}
示例6: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
*
* @param $dataitem SMWDataItem
*
* @return boolean
*/
protected function loadDataItem(DataItem $dataItem)
{
if (!$dataItem instanceof DIBlob) {
return false;
}
$this->m_caption = false;
$this->m_dataitem = $dataItem;
$this->initPropertyChain($dataItem->getString());
return true;
}
示例7: getDataItemExpElement
/**
* Create an SWMExpElement that encodes the data of the given
* dataitem object. This method is meant to be used when exporting a
* dataitem as a subject or object. To get the URI of a property, use
* SMWExporter::getResourceElementForProperty() or
* SMWExporter::getSpecialPropertyResource().
*
* @param $dataItem SMWDataItem
* @return SMWExpElement
*/
public static function getDataItemExpElement(SMWDataItem $dataItem)
{
switch ($dataItem->getDIType()) {
case SMWDataItem::TYPE_NUMBER:
$lit = new SMWExpLiteral($dataItem->getNumber(), 'http://www.w3.org/2001/XMLSchema#double', $dataItem);
return $lit;
case SMWDataItem::TYPE_STRING:
case SMWDataItem::TYPE_BLOB:
$lit = new SMWExpLiteral(smwfHTMLtoUTF8($dataItem->getString()), 'http://www.w3.org/2001/XMLSchema#string', $dataItem);
return $lit;
case SMWDataItem::TYPE_BOOLEAN:
$xsdvalue = $dataItem->getBoolean() ? 'true' : 'false';
$lit = new SMWExpLiteral($xsdvalue, 'http://www.w3.org/2001/XMLSchema#boolean', $dataItem);
return $lit;
case SMWDataItem::TYPE_URI:
$res = new SMWExpResource($dataItem->getURI(), $dataItem);
return $res;
case SMWDataItem::TYPE_TIME:
$gregorianTime = $dataItem->getForCalendarModel(SMWDITime::CM_GREGORIAN);
if ($gregorianTime->getYear() > 0) {
$xsdvalue = str_pad($gregorianTime->getYear(), 4, "0", STR_PAD_LEFT);
} else {
$xsdvalue = '-' . str_pad(1 - $gregorianTime->getYear(), 4, "0", STR_PAD_LEFT);
}
$xsdtype = 'http://www.w3.org/2001/XMLSchema#gYear';
if ($gregorianTime->getPrecision() >= SMWDITime::PREC_YM) {
$xsdtype = 'http://www.w3.org/2001/XMLSchema#gYearMonth';
$xsdvalue .= '-' . str_pad($gregorianTime->getMonth(), 2, "0", STR_PAD_LEFT);
if ($gregorianTime->getPrecision() >= SMWDITime::PREC_YMD) {
$xsdtype = 'http://www.w3.org/2001/XMLSchema#date';
$xsdvalue .= '-' . str_pad($gregorianTime->getDay(), 2, "0", STR_PAD_LEFT);
if ($gregorianTime->getPrecision() == SMWDITime::PREC_YMDT) {
$xsdtype = 'http://www.w3.org/2001/XMLSchema#dateTime';
$xsdvalue .= 'T' . sprintf("%02d", $gregorianTime->getHour()) . ':' . sprintf("%02d", $gregorianTime->getMinute()) . ':' . sprintf("%02d", $gregorianTime->getSecond());
}
}
}
$xsdvalue .= 'Z';
$lit = new SMWExpLiteral($xsdvalue, $xsdtype, $gregorianTime);
return $lit;
case SMWDataItem::TYPE_GEO:
/// TODO
return null;
case SMWDataItem::TYPE_CONTAINER:
return self::makeExportData($dataItem->getSemanticData());
case SMWDataItem::TYPE_WIKIPAGE:
return self::getResourceElementForWikiPage($dataItem);
case SMWDataItem::TYPE_CONCEPT:
/// TODO
return null;
case SMWDataItem::TYPE_PROPERTY:
return self::getResourceElementForProperty($dataItem);
}
}
示例8: getInsertValues
/**
* 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
*
* @return array
*/
public function getInsertValues(SMWDataItem $dataItem)
{
$text = $dataItem->getString();
return array('o_blob' => strlen($text) <= self::MAX_HASH_LENGTH ? null : $text, 'o_hash' => self::makeHash($text));
}
示例9: getInsertValues
/**
* @since 1.8
*
* {@inheritDoc}
*/
public function getInsertValues(DataItem $dataItem)
{
$text = htmlspecialchars_decode(trim($dataItem->getString()), ENT_QUOTES);
return array('o_blob' => strlen($text) <= self::MAX_HASH_LENGTH ? null : ($GLOBALS['wgDBtype'] === 'postgres' ? pg_escape_bytea($text) : $text), 'o_hash' => self::makeHash($text));
}
示例10: addNumbersForDataItem
/**
* @param SMWDataItem $dataItem
* @param float[] $numbers
*/
private function addNumbersForDataItem(SMWDataItem $dataItem, array &$numbers)
{
switch ($dataItem->getDIType()) {
case SMWDataItem::TYPE_NUMBER:
$numbers[] = $dataItem->getNumber();
break;
case SMWDataItem::TYPE_BLOB:
$numbers[] = $dataItem->getString();
break;
case SMWDataItem::TYPE_CONTAINER:
foreach ($dataItem->getDataItems() as $di) {
self::addNumbersForDataItem($di, $numbers);
}
break;
default:
}
}
示例11: getDBkeysFromDataItem
/**
* 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);
}
}
示例12: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem instanceof SMWDIBlob) {
$this->m_dataitem = $dataItem;
$parts = explode(' ', $dataItem->getString(), 3);
if (count($parts) != 3) {
$this->addError(wfMessage('smw_parseerror')->inContentLanguage()->text());
} else {
$this->m_namespace = $parts[0];
$this->m_section = $parts[1];
$this->m_uri = $parts[2];
$this->m_qname = $this->m_namespace . ':' . $this->m_section;
$this->m_caption = "[" . $this->m_uri . " " . $this->m_qname . "] (" . $this->m_name . ")";
}
return true;
} else {
return false;
}
}
示例13: loadDataItem
/**
* @see SMWDataValue::loadDataItem()
* @param $dataitem SMWDataItem
* @return boolean
*/
protected function loadDataItem(SMWDataItem $dataItem)
{
if ($dataItem->getDIType() == SMWDataItem::TYPE_STRING) {
$this->m_dataitem = $dataItem;
$parts = explode(' ', $dataItem->getString(), 3);
if (count($parts) != 3) {
$this->addError(wfMsgForContent('smw_parseerror'));
} else {
$this->m_namespace = $parts[0];
$this->m_section = $parts[1];
$this->m_uri = $parts[2];
$this->m_qname = $this->m_namespace . ':' . $this->m_section;
$this->m_caption = "[" . $this->m_uri . " " . $this->m_qname . "] (" . $this->m_name . ")";
}
return true;
} else {
return false;
}
}