protected function serializeHeader() { $this->namespaces_are_global = true; $this->namespace_block_started = true; $this->pre_ns_buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE rdf:RDF[\n" . "\t<!ENTITY rdf " . $this->makeValueEntityString(SMWExporter::expandURI('&rdf;')) . ">\n" . "\t<!ENTITY rdfs " . $this->makeValueEntityString(SMWExporter::expandURI('&rdfs;')) . ">\n" . "\t<!ENTITY owl " . $this->makeValueEntityString(SMWExporter::expandURI('&owl;')) . ">\n" . "\t<!ENTITY swivt " . $this->makeValueEntityString(SMWExporter::expandURI('&swivt;')) . ">\n" . "\t<!ENTITY wiki " . $this->makeValueEntityString(SMWExporter::expandURI('&wiki;')) . ">\n" . "\t<!ENTITY property " . $this->makeValueEntityString(SMWExporter::expandURI('&property;')) . ">\n" . "\t<!ENTITY wikiurl " . $this->makeValueEntityString(SMWExporter::expandURI('&wikiurl;')) . ">\n" . "]>\n\n" . "<rdf:RDF\n" . "\txmlns:rdf=\"&rdf;\"\n" . "\txmlns:rdfs=\"&rdfs;\"\n" . "\txmlns:owl =\"&owl;\"\n" . "\txmlns:swivt=\"&swivt;\"\n" . "\txmlns:wiki=\"&wiki;\"\n" . "\txmlns:property=\"&property;\""; $this->global_namespaces = array('rdf' => true, 'rdfs' => true, 'owl' => true, 'swivt' => true, 'wiki' => true, 'property' => true); $this->post_ns_buffer .= ">\n\n"; }
/** * Move/rename page * @param $oldtitle * @param $newtitle * @param $pageid * @param $redirid */ function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) { // Save it in parent store now! // We need that so we get all information correctly! $result = parent::changeTitle( $oldtitle, $newtitle, $pageid, $redirid ); // delete old stuff $old_uri = SMWExporter::expandURI( $this->getURI( $oldtitle ) ); $this->removeDataForURI( $old_uri ); $newpage = SMWDataValueFactory::newTypeIDValue( '_wpg' ); $newpage->setValues( $newtitle->getDBkey(), $newtitle->getNamespace(), $pageid ); $semdata = $this->getSemanticData( $newpage ); $this->updateData( $semdata ); $oldpage = SMWDataValueFactory::newTypeIDValue( '_wpg' ); $oldpage->setValues( $oldtitle->getDBkey(), $oldtitle->getNamespace(), $redirid ); $semdata = $this->getSemanticData( $oldpage ); $this->updateData( $semdata, false ); return $result; }
/** * Print basic information about this site. */ public function printWikiInfo() { global $wgSitename, $wgLanguageCode; $this->prepareSerialization(); $this->delay_flush = 35; // don't do intermediate flushes with default parameters // assemble export data: $expData = new SMWExpData(new SMWExpResource('&wiki;#wiki')); $ed = new SMWExpData(SMWExporter::getSpecialNsResource('swivt', 'Wikisite')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('rdf', 'type'), $ed); // basic wiki information $ed = new SMWExpData(new SMWExpLiteral($wgSitename)); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('rdfs', 'label'), $ed); $ed = new SMWExpData(new SMWExpLiteral($wgSitename, null, 'http://www.w3.org/2001/XMLSchema#string')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'siteName'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SMWExporter::expandURI('&wikiurl;'), null, 'http://www.w3.org/2001/XMLSchema#string')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'pagePrefix'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SMW_VERSION, null, 'http://www.w3.org/2001/XMLSchema#string')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'smwVersion'), $ed); $ed = new SMWExpData(new SMWExpLiteral($wgLanguageCode, null, 'http://www.w3.org/2001/XMLSchema#string')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'langCode'), $ed); $mainpage = Title::newMainPage(); if (!is_null($mainpage)) { $ed = new SMWExpData(new SMWExpResource($mainpage->getFullURL())); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'mainPage'), $ed); } // statistical information $ed = new SMWExpData(new SMWExpLiteral(SiteStats::pages(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'pageCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::articles(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'contentPageCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::images(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'mediaCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::edits(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'editCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::views(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'viewCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::users(), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'userCount'), $ed); $ed = new SMWExpData(new SMWExpLiteral(SiteStats::numberingroup('sysop'), null, 'http://www.w3.org/2001/XMLSchema#int')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('swivt', 'adminCount'), $ed); $this->serializer->startSerialization(); $this->serializer->serializeExpData(SMWExporter::getOntologyExpData('')); $this->serializer->serializeExpData($expData); // link to list of existing pages: if (strpos(SMWExporter::expandURI('&wikiurl;'), '?') === false) { // check whether we have title as a first parameter or in URL $nexturl = SMWExporter::expandURI('&export;?offset=0'); } else { $nexturl = SMWExporter::expandURI('&export;&offset=0'); } $expData = new SMWExpData(new SMWExpResource($nexturl)); $ed = new SMWExpData(SMWExporter::getSpecialNsResource('owl', 'Thing')); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('rdf', 'type'), $ed); $ed = new SMWExpData(new SMWExpResource($nexturl)); $expData->addPropertyObjectValue(SMWExporter::getSpecialNsResource('rdfs', 'isDefinedBy'), $ed); $this->serializer->serializeExpData($expData); $this->serializer->finishSerialization(); $this->flush(true); }
/** * Return a fully qualified URL that points to the link target (whether internal or not). * This function might be used when the URL is needed outside normal links, e.g. in the HTML * header or in some metadata file. For making normal links, getText() should be used. * * @return string */ public function getURL() { if ( $this->mInternal ) { $title = Title::newFromText( $this->mTarget ); if ( !is_null( $title ) ) { return $title->getFullURL( SMWInfolink::encodeParameters( $this->mParams, false ) ); } else { return ''; // the title was bad, normally this would indicate a software bug } } else { if ( count( $this->mParams ) > 0 ) { if ( strpos( SMWExporter::expandURI( '&wikiurl;' ), '?' ) === false ) { $target = $this->mTarget . '?' . SMWInfolink::encodeParameters( $this->mParams, false ); } else { $target = $this->mTarget . '&' . SMWInfolink::encodeParameters( $this->mParams, false ); } } else { $target = $this->mTarget; } return $target; } }
/** * Get the Turtle serialization string for the given SMWExpElement. The * method just computes a name, and does not serialize triples, so the * parameter must be an SMWExpResource or SMWExpLiteral, no SMWExpData. * * @param $expElement SMWExpElement being SMWExpLiteral or SMWExpResource * @return string */ public static function getTurtleNameForExpElement(SMWExpElement $expElement) { if ($expElement instanceof SMWExpResource) { if ($expElement->isBlankNode()) { return '[]'; } elseif ($expElement instanceof SMWExpNsResource && $expElement->hasAllowedLocalName()) { return $expElement->getQName(); } else { return '<' . str_replace('>', '\\>', SMWExporter::expandURI($expElement->getUri())) . '>'; } } elseif ($expElement instanceof SMWExpLiteral) { $lexicalForm = '"' . str_replace(array('\\', "\n", '"'), array('\\\\', "\\n", '\\"'), $expElement->getLexicalForm()) . '"'; $dt = $expElement->getDatatype(); if ($dt !== '' && $dt != 'http://www.w3.org/2001/XMLSchema#string') { $count = 0; $newdt = str_replace('http://www.w3.org/2001/XMLSchema#', 'xsd:', $dt, $count); return $count == 1 ? "{$lexicalForm}^^{$newdt}" : "{$lexicalForm}^^<{$dt}>"; } else { return $lexicalForm; } } else { throw new InvalidArgumentException('The method can only serialize atomic elements of type SMWExpResource or SMWExpLiteral.'); } }