/** * @see ApiBase::execute */ public function execute() { $params = $this->extractRequestParams(); $propertyListByApiRequest = new PropertyListByApiRequest(ApplicationFactory::getInstance()->getStore()); $propertyListByApiRequest->setLimit($params['limit']); $propertyListByApiRequest->findPropertyListFor($params['property']); foreach ($propertyListByApiRequest->getNamespaces() as $ns) { $uri = NamespaceUriFinder::getUri($ns); if (!$uri) { continue; } $this->getResult()->addValue(null, 'xmlns:' . $ns, $uri); } $data = $propertyListByApiRequest->getPropertyList(); // I'm without words for this utter nonsense introduced here // because property keys can have a underscore _MDAT or for that matter // any other data field can // https://www.mediawiki.org/wiki/API:JSON_version_2 // " ... can indicate that a property beginning with an underscore is not metadata using" if (method_exists($this->getResult(), 'setPreserveKeysList')) { $this->getResult()->setPreserveKeysList($data, array_keys($data)); } $this->getResult()->addValue(null, 'query', $data); $this->getResult()->addValue(null, 'version', 0.1); $this->getResult()->addValue(null, 'query-continue-offset', $propertyListByApiRequest->getContinueOffset()); $this->getResult()->addValue(null, 'meta', $propertyListByApiRequest->getMeta()); }
/** * @dataProvider namespaceProvider */ public function testGetUriForNamespaceKey($key, $expected) { $this->assertInternalType($expected, NamespaceUriFinder::getUri($key)); }
/** * Get the URI of a standard namespace prefix used in SMW, or the empty * string if the prefix is not known. * * @param $shortName string id (prefix) of the namespace * @return string of the expanded URI */ public static function getNamespaceUri($shortName) { self::initBaseURIs(); if (($uri = NamespaceUriFinder::getUri($shortName)) !== false) { return $uri; } switch ($shortName) { case 'wiki': return self::$m_ent_wiki; case 'wikiurl': return self::$m_ent_wikiurl; case 'property': return self::$m_ent_property; case 'category': return self::$m_ent_category; case 'export': return self::$m_exporturl; case 'owl': return 'http://www.w3.org/2002/07/owl#'; case 'rdf': return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; case 'rdfs': return 'http://www.w3.org/2000/01/rdf-schema#'; case 'swivt': return 'http://semantic-mediawiki.org/swivt/1.0#'; case 'xsd': return 'http://www.w3.org/2001/XMLSchema#'; default: return ''; } }