/** * Prepare page handlers, which represent wiki pages to be written to/deleted from, * and the corresponding facts to add/remove */ private function preparePageHandlers() { // The page below should not be deleted on delete operations if ( !$this->m_delete ) { // Add type info to the Original URI property $property_hastypeurl = array( array( 'p' => 'Has type', 'v' => 'URL' ) ); $origuripage = new RDFIOPageHandler( 'Original URI', SMW_NS_PROPERTY, $property_hastypeurl ); $this->addToPages( $origuripage ); } // Prepare for storing the data to write in internal data structure ($this->m_pages) $unique_subject_uris = $this->getUniqueSubjectURIs(); foreach ( $unique_subject_uris as $subject_uri ) { $properties = array(); // A URIResolver URI indicates that internal titles only are used and we have no Original URI available if ( !$this->m_delete && !RDFIOUtils::isURIResolverURI( $subject_uri ) && !RDFIOUtils::isArcUntitledNode( $subject_uri ) ) { // Add the Original URI fact to the list of properties $properties[0] = $this->createOrigURIPropertyArray( $subject_uri ); $properties[1] = $this->createEquivURIPropertyArray( $subject_uri ); $i++; } $wikititle = $this->getWikiTitleForURI( $subject_uri ); $triplesforpage = $this->getTriplesForSubject( $subject_uri ); $i = 2; foreach ( $triplesforpage as $triple ) { $propertyuri = $triple['p']; $valueorig = $triple['o']; $valuetype = $triple['o_type']; $property = $this->getWikiTitleForURI( $propertyuri, $isproperty = true ); if ( $valuetype == 'uri' ) { $value = $this->getWikiTitleForURI( $valueorig ); } else { $value = RDFIOUtils::sanitizeSMWValue( $valueorig ); } $properties[$i] = array( 'p' => $property, 'v' => $value ); $i++; } $this->addToPages( new RDFIOPageHandler( $wikititle, NS_MAIN, $properties ) ); } // The data generated below should not be deleted when doing delete operations, and thus, // pagehandlers for them should not be prepared on delete. if ( !$this->m_delete ) { // Prepare property pages $unique_property_uris = $this->getUniquePropertyURIs(); foreach ( $unique_property_uris as $property_uri => $property_uridata ) { $wikititle = $this->getWikiTitleForURI( $property_uri, $isproperty = true ); $type = $this->convertARCTypeToSMWType( $property_uridata['type'], $property_uridata['datatype'] ); $property_hastype = array( 'p' => 'Has type', 'v' => $type ); // A URIResolver URI indicates that internal titles only are used and we have no Original URI available if ( !RDFIOUtils::isURIResolverURI( $property_uri ) && !RDFIOUtils::isArcUntitledNode( $wikititle ) ) { $property_origuri = $this->createOrigURIPropertyArray( $property_uri ); $property_equivuri = $this->createEquivURIPropertyArray( $property_uri ); $properties = array( $property_origuri, $property_equivuri, $property_hastype ); } else { $properties = array( $property_hastype ); } $propertypage = new RDFIOPageHandler( $wikititle, SMW_NS_PROPERTY, $properties ); $this->addToPages( $propertypage ); } // Prepare value pages // TODO: Look for a way to merge with the above code, or otherwise refactor ... $unique_value_uris = $this->getUniqueValueURIs(); foreach ( $unique_value_uris as $unique_value_uri ) { $wikititle = $this->getWikiTitleForURI( $unique_value_uri ); // A URIResolver URI indicates that internal titles only are used and we have no Original URI available if ( !RDFIOUtils::isURIResolverURI( $unique_value_uri ) && !RDFIOUtils::isArcUntitledNode( $unique_value_uri ) ) { $value_origuri = $this->createOrigURIPropertyArray( $unique_value_uri ); $value_equivuri = $this->createEquivURIPropertyArray( $unique_value_uri ); $values = array( $value_origuri, $value_equivuri ); } $valuepage = new RDFIOPageHandler( $wikititle, NS_MAIN, $values ); $this->addToPages( $valuepage ); } } }