本文整理汇总了PHP中SMW\SemanticData::getSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP SemanticData::getSubject方法的具体用法?PHP SemanticData::getSubject怎么用?PHP SemanticData::getSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\SemanticData
的用法示例。
在下文中一共展示了SemanticData::getSubject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWikiPage
/**
* @since 1.0
*
* @return WikiPage
*/
public function getWikiPage()
{
if ($this->page === null) {
$this->page = $this->appFactory->newWikiPage($this->semanticData->getSubject()->getTitle());
//$this->loadRegisteredObject( 'WikiPage' );
}
return $this->page;
}
示例2: addAnnotation
/**
* @since 1.0
*
* @return boolean
*/
public function addAnnotation()
{
if (!$this->hasShortUrlUtils()) {
throw new RuntimeException('Expected class ShortUrlUtils to be available');
}
$shortURL = $this->getShortUrl($this->semanticData->getSubject()->getTitle());
if ($shortURL !== null) {
$this->semanticData->addPropertyObjectValue(new DIProperty(PropertyRegistry::getInstance()->getPropertyId('_SHORTURL')), new DIUri('http', $shortURL, '', ''));
}
return true;
}
示例3: testGetPropertyValues
public function testGetPropertyValues()
{
$instance = new SemanticData(DIWikiPage::newFromTitle(Title::newFromText(__METHOD__)));
$this->assertInstanceOf('SMW\\DIWikiPage', $instance->getSubject());
$this->assertEmpty($instance->getPropertyValues(new DIProperty('Foo', true)));
$this->assertEmpty($instance->getPropertyValues(new DIProperty('Foo')));
}
示例4: deleteSubject
/**
* @see SMWStore::deleteSubject
*
* @since 1.8
* @param Title $title
*/
public function deleteSubject(Title $title)
{
// @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
wfRunHooks('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
wfRunHooks('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
$id = $this->store->getObjectIds()->getSMWPageID($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), '', false);
$emptySemanticData = new SemanticData(DIWikiPage::newFromTitle($title));
$subobjects = $this->getSubobjects($emptySemanticData->getSubject());
$this->doDataUpdate($emptySemanticData);
if ($title->getNamespace() === SMW_NS_CONCEPT) {
// make sure to clear caches
$db = $this->store->getConnection();
$db->delete('smw_fpt_conc', array('s_id' => $id), 'SMW::deleteSubject::Conc');
$db->delete(SMWSQLStore3::CONCEPT_CACHE_TABLE, array('o_id' => $id), 'SMW::deleteSubject::Conccache');
}
// Mark subject/subobjects with a special IW, the final removal is being
// triggered by the `ByIdDataRebuildDispatcher`
$this->store->getObjectIds()->updateInterwikiField($id, $emptySemanticData->getSubject(), SMW_SQL3_SMWDELETEIW);
foreach ($subobjects as $smw_id => $subobject) {
$this->store->getObjectIds()->updateInterwikiField($smw_id, $subobject, SMW_SQL3_SMWDELETEIW);
}
// 1.9.0.1
// The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
// the ArticleDelete hook
// @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
wfRunHooks('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
wfRunHooks('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
}
示例5: testGetHash
public function testGetHash()
{
$instance = new SemanticData(DIWikiPage::newFromText(__METHOD__));
$instance->addDataValue(DataValueFactory::getInstance()->newDataValueByText('Has fooQuex', 'Bar'));
$subobject = $this->newSubobject($instance->getSubject()->getTitle());
$instance->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$this->assertInternalType('string', $instance->getHash());
}
示例6: doSerialize
private function doSerialize(SemanticData $semanticData)
{
$data = array('subject' => $semanticData->getSubject()->getSerialization(), 'data' => $this->serializeProperty($semanticData));
$subobjects = $this->serializeSubobject($semanticData->getSubSemanticData());
if ($subobjects !== array()) {
$data['sobj'] = $subobjects;
}
return $data;
}
示例7: notifyDispatcher
private function notifyDispatcher($addJob = true)
{
if ($addJob && !$this->hasDiff) {
$dispatchContext = EventHandler::getInstance()->newDispatchContext();
$dispatchContext->set('subject', $this->semanticData->getSubject());
EventHandler::getInstance()->getEventDispatcher()->dispatch('property.specification.change', $dispatchContext);
$this->hasDiff = true;
}
}
示例8: doRealUpdate
private function doRealUpdate()
{
$this->store->setUpdateJobsEnabledState($this->updateJobsEnabledState);
if ($this->processSemantics) {
$this->store->updateData($this->semanticData);
} else {
$this->store->clearData($this->semanticData->getSubject());
}
return true;
}
示例9: testDoSparqlDataUpdateOnMockBaseStore
public function testDoSparqlDataUpdateOnMockBaseStore()
{
$semanticData = new SemanticData(new DIWikiPage(__METHOD__, NS_MAIN));
$semanticData->addPropertyObjectValue(new DIProperty('Foo'), $semanticData->getSubject());
$repositoryResult = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\RepositoryResult')->disableOriginalConstructor()->getMock();
$baseStore = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$sparqlDatabase = $this->getMockBuilder('\\SMWSparqlDatabase')->disableOriginalConstructor()->getMock();
$sparqlDatabase->expects($this->atLeastOnce())->method('select')->will($this->returnValue($repositoryResult));
$sparqlDatabase->expects($this->once())->method('insertData');
$connectionManager = $this->getMockBuilder('\\SMW\\ConnectionManager')->disableOriginalConstructor()->getMock();
$connectionManager->expects($this->any())->method('getConnection')->will($this->returnValue($sparqlDatabase));
$instance = new SPARQLStore($baseStore);
$instance->setConnectionManager($connectionManager);
$instance->doSparqlDataUpdate($semanticData);
}
示例10: createFromSemanticData
/**
* @since 2.4
*
* @param SemanticData $semanticData
*
* @return string
*/
public static function createFromSemanticData(SemanticData $semanticData)
{
$hash = array();
$hash[] = $semanticData->getSubject()->getSerialization();
foreach ($semanticData->getProperties() as $property) {
$hash[] = $property->getKey();
foreach ($semanticData->getPropertyValues($property) as $di) {
$hash[] = $di->getSerialization();
}
}
foreach ($semanticData->getSubSemanticData() as $data) {
$hash[] = $data->getHash();
}
sort($hash);
return md5(implode('#', $hash));
}
示例11: deleteSubject
/**
* @see SMWStore::deleteSubject
*
* @since 1.8
* @param Title $title
*/
public function deleteSubject(Title $title)
{
// @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
\Hooks::run('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
\Hooks::run('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
// Fetch all possible matches (including any duplicates created by
// incomplete rollback or DB deadlock)
$ids = $this->store->getObjectIds()->getListOfIdMatchesFor($title->getDBkey(), $title->getNamespace(), $title->getInterwiki());
$subject = DIWikiPage::newFromTitle($title);
$emptySemanticData = new SemanticData($subject);
$this->entitySubobjectListIterator->setSubject($emptySemanticData->getSubject());
$subobjects = $this->entitySubobjectListIterator->getIterator();
$this->doDataUpdate($emptySemanticData);
foreach ($ids as $id) {
$this->doDelete($id, $subject, $subobjects);
}
// @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
\Hooks::run('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
\Hooks::run('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
}
示例12: deleteSubject
/**
* @see SMWStore::deleteSubject
*
* @since 1.8
* @param Title $title
*/
public function deleteSubject(Title $title)
{
// @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
\Hooks::run('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
\Hooks::run('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
// Fetch all possible matches (including any duplicates created by
// incomplete rollback or DB deadlock)
$ids = $this->store->getObjectIds()->getListOfIdMatchesFor($title->getDBkey(), $title->getNamespace(), $title->getInterwiki());
$subject = DIWikiPage::newFromTitle($title);
$emptySemanticData = new SemanticData($subject);
$subobjects = $this->getSubobjects($emptySemanticData->getSubject());
$this->doDataUpdate($emptySemanticData);
foreach ($ids as $id) {
$this->doDeleteReferencesFor($id, $subject, $subobjects);
}
// 1.9.0.1
// The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
// the ArticleDelete hook
// @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
\Hooks::run('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
\Hooks::run('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
}
示例13: mapToInsertValueFormat
/**
* Create an array of rows to insert into property tables in order to
* store the given SMWSemanticData. The given $sid (subject page id) is
* used directly and must belong to the subject of the data container.
* Sortkeys are ignored since they are not stored in a property table
* but in the ID table.
*
* The returned array uses property table names as keys and arrays of
* table rows as values. Each table row is an array mapping column
* names to values.
*
* @note Property tables that do not use ids as subjects are ignored.
* This just excludes redirects that are handled differently anyway;
* it would not make a difference to include them here.
*
* @since 1.8
*
* @param integer $sid
* @param SemanticData $semanticData
*
* @return array
*/
private function mapToInsertValueFormat($sid, SemanticData $semanticData)
{
$updates = array();
$subject = $semanticData->getSubject();
$propertyTables = $this->store->getPropertyTables();
foreach ($semanticData->getProperties() as $property) {
$tableId = $this->store->findPropertyTableID($property);
// not stored in a property table, e.g., sortkeys
if ($tableId === null) {
continue;
}
// "Notice: Undefined index"
if (!isset($propertyTables[$tableId])) {
throw new RuntimeException("Unable to find a property table for " . $property->getKey());
}
$propertyTable = $propertyTables[$tableId];
// not using subject ids, e.g., redirects
if (!$propertyTable->usesIdSubject()) {
continue;
}
$insertValues = array('s_id' => $sid);
if (!$propertyTable->isFixedPropertyTable()) {
$insertValues['p_id'] = $this->store->getObjectIds()->makeSMWPropertyID($property);
}
foreach ($semanticData->getPropertyValues($property) as $dataItem) {
if ($dataItem instanceof DIError) {
// ignore error values
continue;
}
if (!array_key_exists($propertyTable->getName(), $updates)) {
$updates[$propertyTable->getName()] = array();
}
$dataItemValues = $this->store->getDataItemHandlerForDIType($dataItem->getDIType())->getInsertValues($dataItem);
// Ensure that the sortkey is a string
if (isset($dataItemValues['o_sortkey'])) {
$dataItemValues['o_sortkey'] = (string) $dataItemValues['o_sortkey'];
}
// Make sure to build a unique set without duplicates which could happen
// if an annotation is made to a property that has a redirect pointing
// to the same p_id
$insertValues = array_merge($insertValues, $dataItemValues);
$insertValuesHash = md5(implode('#', $insertValues));
$updates[$propertyTable->getName()][$insertValuesHash] = $insertValues;
}
}
// Special handling of Concepts
if ($subject->getNamespace() === SMW_NS_CONCEPT && $subject->getSubobjectName() == '') {
$this->fetchConceptTableInserts($sid, $updates);
}
return $updates;
}
示例14: removeSubSemanticData
/**
* Remove data about a subobject.
* If the removed data is not about a subobject of this object,
* it will silently be ignored (nothing to remove). Likewise,
* removing data that is not present does not change anything.
*
* @since 1.8
* @param SMWSemanticData
*/
public function removeSubSemanticData(SemanticData $semanticData)
{
if ($semanticData->getSubject()->getDBkey() !== $this->getSubject()->getDBkey()) {
return;
}
$subobjectName = $semanticData->getSubject()->getSubobjectName();
if ($this->hasSubSemanticData($subobjectName)) {
$this->subSemanticData[$subobjectName]->removeDataFrom($semanticData);
if ($this->subSemanticData[$subobjectName]->isEmpty()) {
unset($this->subSemanticData[$subobjectName]);
}
}
}
示例15: updateData
/**
* Update the semantic data stored for some individual. The data is
* given as a SemanticData object, which contains all semantic data
* for one particular subject.
*
* @param SemanticData $semanticData
*/
public function updateData(SemanticData $semanticData)
{
/**
* @since 1.6
*/
wfRunHooks('SMWStore::updateDataBefore', array($this, $semanticData));
// Invalidate the page, so data stored on it gets displayed immediately in queries.
$pageUpdater = ApplicationFactory::getInstance()->newMwCollaboratorFactory()->newPageUpdater();
if ($GLOBALS['smwgAutoRefreshSubject'] && $pageUpdater->canUpdate()) {
$pageUpdater->addPage($semanticData->getSubject()->getTitle());
$pageUpdater->doPurgeParserCache();
$pageUpdater->doPurgeHtmlCache();
}
$this->doDataUpdate($semanticData);
/**
* @since 1.6
*/
wfRunHooks('SMWStore::updateDataAfter', array($this, $semanticData));
}