本文整理汇总了PHP中SMW\DIWikiPage::setSortKey方法的典型用法代码示例。如果您正苦于以下问题:PHP DIWikiPage::setSortKey方法的具体用法?PHP DIWikiPage::setSortKey怎么用?PHP DIWikiPage::setSortKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\DIWikiPage
的用法示例。
在下文中一共展示了DIWikiPage::setSortKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSemanticData
/**
* @see SMWStore::getSemanticData()
* @since 1.8
*
* @param DIWikiPage $subject
* @param string[]|bool $filter
*/
public function getSemanticData(DIWikiPage $subject, $filter = false)
{
// *** Find out if this subject exists ***//
$sortKey = '';
$sid = $this->store->smwIds->getSMWPageIDandSort($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subject->getSubobjectName(), $sortKey, true, true);
// Ensures that a cached item to contain an expected sortKey when
// for example the ID was just created and the sortKey from the DB
// is empty otherwise the DB wins over the invoked sortKey
if (!$sortKey) {
$sortKey = $subject->getSortKey();
}
$subject->setSortKey($sortKey);
if ($sid == 0) {
// We consider redirects for getting $sid,
// so $sid == 0 also means "no redirects".
return new SMWSemanticData($subject);
}
$propertyTableHashes = $this->store->smwIds->getPropertyTableHashes($sid);
foreach ($this->store->getPropertyTables() as $tid => $proptable) {
if (!array_key_exists($proptable->getName(), $propertyTableHashes)) {
continue;
}
if ($filter !== false) {
$relevant = false;
foreach ($filter as $typeId) {
$diType = DataTypeRegistry::getInstance()->getDataItemId($typeId);
$relevant = $relevant || $proptable->getDiType() == $diType;
if ($relevant) {
break;
}
}
if (!$relevant) {
continue;
}
}
$this->getSemanticDataFromTable($sid, $subject, $proptable);
}
// Note: the sortkey is always set but belongs to no property table,
// hence no entry in $this->store->m_sdstate[$sid] is made.
self::$in_getSemanticData++;
$this->initSemanticDataCache($sid, $subject);
// Avoid adding a sortkey for an already extended stub
if (!$this->store->m_semdata[$sid]->hasProperty(new DIProperty('_SKEY'))) {
$this->store->m_semdata[$sid]->addPropertyStubValue('_SKEY', array('', $sortKey));
}
self::$in_getSemanticData--;
return $this->store->m_semdata[$sid];
}
示例2: getSemanticData
/**
* @see SMWStore::getSemanticData()
* @since 1.8
*
* @param DIWikiPage $subject
* @param string[]|bool $filter
*/
public function getSemanticData(DIWikiPage $subject, $filter = false)
{
// *** Find out if this subject exists ***//
$sortKey = '';
$sid = $this->store->smwIds->getSMWPageIDandSort($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subject->getSubobjectName(), $sortKey, true, true);
$subject->setSortKey($sortKey);
if ($sid == 0) {
// We consider redirects for getting $sid,
// so $sid == 0 also means "no redirects".
return new SMWSemanticData($subject);
}
$propertyTableHashes = $this->store->smwIds->getPropertyTableHashes($sid);
foreach ($this->store->getPropertyTables() as $tid => $proptable) {
if (!array_key_exists($proptable->getName(), $propertyTableHashes)) {
continue;
}
if ($filter !== false) {
$relevant = false;
foreach ($filter as $typeId) {
$diType = DataTypeRegistry::getInstance()->getDataItemId($typeId);
$relevant = $relevant || $proptable->getDiType() == $diType;
if ($relevant) {
break;
}
}
if (!$relevant) {
continue;
}
}
$this->getSemanticDataFromTable($sid, $subject, $proptable);
}
// Note: the sortkey is always set but belongs to no property table,
// hence no entry in $this->store->m_sdstate[$sid] is made.
self::$in_getSemanticData++;
$this->initSemanticDataCache($sid, $subject);
$this->store->m_semdata[$sid]->addPropertyStubValue('_SKEY', array('', $sortKey));
self::$in_getSemanticData--;
return $this->store->m_semdata[$sid];
}
示例3: newDiWikiPage
private function newDiWikiPage($dbkeys)
{
$diWikiPage = new DIWikiPage($dbkeys[0], intval($dbkeys[1]), $dbkeys[2], $dbkeys[4]);
$diWikiPage->setSortKey($dbkeys[3]);
return $diWikiPage;
}
示例4: testSortKeyRoundtrip
/**
* @dataProvider sortKeyProvider
*/
public function testSortKeyRoundtrip($title, $sortkey, $expected)
{
$instance = new DIWikiPage($title, NS_MAIN);
$instance->setSortKey($sortkey);
$this->assertEquals($expected, $instance->getSortKey());
}
示例5: newMappingIterator
/**
* Fetch all subobjects for a given subject using a lazy-mapping iterator
* in order to only resolve one subobject per iteration step.
*
* @since 2.5
*
* @param DIWikiPage $subject
*
* @return MappingIterator
*/
private function newMappingIterator(DIWikiPage $subject)
{
$callback = function ($row) use($subject) {
// #1955
if ($subject->getNamespace() === SMW_NS_PROPERTY) {
$property = new DIProperty($subject->getDBkey());
$subobject = $property->getCanonicalDiWikiPage($row->smw_subobject);
} else {
$subobject = new DIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $row->smw_subobject);
}
$subobject->setSortKey($row->smw_sortkey);
$subobject->setId($row->smw_id);
return $subobject;
};
return $this->iteratorFactory->newMappingIterator($this->newResultIterator($subject), $callback);
}