private function defineElementsForDiWikiPage(DIWikiPage $diWikiPage, $modifier)
 {
     $localName = '';
     if ($diWikiPage->getNamespace() === SMW_NS_PROPERTY) {
         $namespace = Exporter::getInstance()->getNamespaceUri('property');
         $namespaceId = 'property';
         $localName = Escaper::encodeUri(rawurlencode($diWikiPage->getDBkey()));
     }
     if ($localName === '' || in_array($localName[0], array('-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) {
         $namespace = Exporter::getInstance()->getNamespaceUri('wiki');
         $namespaceId = 'wiki';
         $localName = Escaper::encodePage($diWikiPage);
     }
     // "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not
     // occuring in MW titles).
     if ($modifier !== '') {
         $localName .= '-23' . Escaper::encodeUri(rawurlencode($modifier));
     }
     return array($localName, $namespace, $namespaceId);
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider decodeUriProvider
  */
 public function testDecodeUri($uri, $expected)
 {
     $this->assertEquals($expected, Escaper::decodeUri($uri));
     $this->assertEquals($uri, Escaper::encodeUri(Escaper::decodeUri($uri)));
 }
 /**
  * Make sure that necessary base URIs are initialised properly.
  */
 public static function initBaseURIs()
 {
     if (self::$m_exporturl !== false) {
         return;
     }
     global $wgContLang, $wgServer, $wgArticlePath;
     global $smwgNamespace;
     // complete namespace for URIs (with protocol, usually http://)
     if ('' == $smwgNamespace) {
         $resolver = SpecialPage::getTitleFor('URIResolver');
         $smwgNamespace = $resolver->getFullURL() . '/';
     } elseif ($smwgNamespace[0] == '.') {
         $resolver = SpecialPage::getTitleFor('URIResolver');
         $smwgNamespace = "http://" . substr($smwgNamespace, 1) . $resolver->getLocalURL() . '/';
     }
     // The article name must be the last part of wiki URLs for proper OWL/RDF export:
     self::$m_ent_wikiurl = $wgServer . str_replace('$1', '', $wgArticlePath);
     self::$m_ent_wiki = $smwgNamespace;
     $property = $GLOBALS['smwgExportBCNonCanonicalFormUse'] ? urlencode(str_replace(' ', '_', $wgContLang->getNsText(SMW_NS_PROPERTY))) : 'Property';
     $category = $GLOBALS['smwgExportBCNonCanonicalFormUse'] ? urlencode(str_replace(' ', '_', $wgContLang->getNsText(NS_CATEGORY))) : 'Category';
     self::$m_ent_property = self::$m_ent_wiki . Escaper::encodeUri($property . ':');
     self::$m_ent_category = self::$m_ent_wiki . Escaper::encodeUri($category . ':');
     $title = SpecialPage::getTitleFor('ExportRDF');
     self::$m_exporturl = self::$m_ent_wikiurl . $title->getPrefixedURL();
 }
Ejemplo n.º 4
0
 /**
  * Make sure that necessary base URIs are initialised properly.
  */
 public static function initBaseURIs()
 {
     if (self::$m_exporturl !== false) {
         return;
     }
     global $wgContLang, $wgServer, $wgArticlePath;
     global $smwgNamespace;
     // complete namespace for URIs (with protocol, usually http://)
     $resolver = Title::makeTitle(NS_SPECIAL, 'URIResolver');
     if ('' == $smwgNamespace) {
         $smwgNamespace = $resolver->getFullURL() . '/';
     } elseif ($smwgNamespace[0] == '.') {
         $smwgNamespace = "http://" . substr($smwgNamespace, 1) . $resolver->getLocalURL() . '/';
     }
     // The article name must be the last part of wiki URLs for proper OWL/RDF export:
     self::$m_ent_wikiurl = $wgServer . str_replace('$1', '', $wgArticlePath);
     self::$m_ent_wiki = $smwgNamespace;
     $property = $GLOBALS['smwgExportBCNonCanonicalFormUse'] ? urlencode(str_replace(' ', '_', $wgContLang->getNsText(SMW_NS_PROPERTY))) : 'Property';
     $category = $GLOBALS['smwgExportBCNonCanonicalFormUse'] ? urlencode(str_replace(' ', '_', $wgContLang->getNsText(NS_CATEGORY))) : 'Category';
     self::$m_ent_property = self::$m_ent_wiki . Escaper::encodeUri($property . ':');
     self::$m_ent_category = self::$m_ent_wiki . Escaper::encodeUri($category . ':');
     $title = Title::makeTitle(NS_SPECIAL, 'ExportRDF');
     self::$m_exporturl = self::$m_ent_wikiurl . $title->getPrefixedURL();
     // Canonical form, the title object always contains a wgContLang reference
     // therefore replace it
     if (!$GLOBALS['smwgExportBCNonCanonicalFormUse']) {
         $localizer = Localizer::getInstance();
         self::$m_ent_property = $localizer->getCanonicalizedUrlByNamespace(NS_SPECIAL, self::$m_ent_property);
         self::$m_ent_category = $localizer->getCanonicalizedUrlByNamespace(NS_SPECIAL, self::$m_ent_category);
         self::$m_ent_wiki = $localizer->getCanonicalizedUrlByNamespace(NS_SPECIAL, self::$m_ent_wiki);
         self::$m_exporturl = $localizer->getCanonicalizedUrlByNamespace(NS_SPECIAL, self::$m_exporturl);
     }
 }