/** * Constructor for a single indi in the file. */ public function __construct(SMWDIWikiPage $page) { $values = array(); $storage = smwfGetStore(); $this->page = $page; $this->title = $page->getTitle(); $properties = SemanticGenealogy::getProperties(); foreach ($properties as $key => $prop) { $values = $storage->getPropertyValues($page, $prop); if (count($values) != 0 && property_exists('PersonPageValues', $key)) { $this->{$key} = $values[0]; } } if (!$this->fullname instanceof SMWDIBlob) { if ($this->surname instanceof SMWDIBlob && $this->surname->getString() != '') { $fullname = ''; if ($this->givenname instanceof SMWDIBlob) { $fullname .= $this->givenname->getString() . ' '; } $this->fullname = new SMWDIBlob($fullname . $this->surname->getString()); } else { $this->fullname = new SMWDIBlob($this->title->getText()); } } }
/** * Retrieve a copy of the semantic data for a wiki page, possibly filtering * it so that only essential properties are included (in some cases, we only * want to export stub information about a page). * We make a copy of the object since we may want to add more data later on * and we do not want to modify the store's result which may be used for * caching purposes elsewhere. */ protected function getSemanticData(SMWDIWikiPage $diWikiPage, $core_props_only) { // Issue 619 // Resolve the redirect target and return a container with information // about the redirect if ($diWikiPage->getTitle() !== null && $diWikiPage->getTitle()->isRedirect()) { try { $redirectTarget = $this->getDeepRedirectTargetResolver()->findRedirectTargetFor($diWikiPage->getTitle()); } catch (\Exception $e) { $redirectTarget = null; } // Couldn't resolve the redirect which is most likely caused by a // circular redirect therefore we give up if ($redirectTarget === null) { return null; } $semData = new SemanticData($diWikiPage); $semData->addPropertyObjectValue(new DIProperty('_REDI'), DIWikiPage::newFromTitle($redirectTarget)); return $semData; } $semdata = \SMW\StoreFactory::getStore()->getSemanticData($diWikiPage, $core_props_only ? array('__spu', '__typ', '__imp') : false); // advise store to retrieve only core things if ($core_props_only) { // be sure to filter all non-relevant things that may still be present in the retrieved $result = new SMWSemanticData($diWikiPage); foreach (array('_URI', '_TYPE', '_IMPO') as $propid) { $prop = new SMW\DIProperty($propid); $values = $semdata->getPropertyValues($prop); foreach ($values as $dv) { $result->addPropertyObjectValue($prop, $dv); } } } else { $result = clone $semdata; } return $result; }