function getParams() { if (!empty($_SERVER['QUERY_STRING'])) { return queryStringToParams($_SERVER['QUERY_STRING']); } else { return array(); } }
function test_paramsToSparql() { $params = queryStringToParams("foo.bar={school}"); $expected = " ?item gc:testPropWithApiLabel ?foo . ?foo gc:testPropWithRdfsLabel <http://education.data.gov.uk/id/school/12345> . "; $actual = $this->SW->paramsToSparql($params); $this->assertEquals(strip_whitespace($expected), strip_whitespace($actual), " Failed translating foo.bar={school}"); $params = queryStringToParams("bar.foo.age={school}"); $expected = "\n ?item gc:testPropWithRdfsLabel ?bar .\n ?bar gc:testPropWithApiLabel ?bar_foo . \n ?bar_foo gc:age <http://education.data.gov.uk/id/school/12345> . "; $actual = $this->SW->paramsToSparql($params); $this->assertEquals(strip_whitespace($expected), strip_whitespace($actual), " Failed translating bar.foo.age={school}"); }
function getParams() { if ($this->params != null) { return $this->params; } if (!empty($_SERVER['QUERY_STRING'])) { $this->params = queryStringToParams($_SERVER['QUERY_STRING']); } else { $this->params = array(); } return $this->params; }
function getParameterTemplates($template) { $query = parse_url($template, PHP_URL_QUERY); $params = queryStringToParams($query); return $params; }
function test_queryStringToParams() { $qs = '?a.b=Hello%20World&a_b=Die%20&subcategory.label=Future%20Media%20%26%20Technology'; $expected = array('a.b' => 'Hello World', 'a_b' => 'Die ', 'subcategory.label' => 'Future Media & Technology'); $this->assertEquals($expected, queryStringToParams($qs)); }
function addTermBindingsMetadata() { $this->DataGraph->add_resource_triple($this->pageUri, API . 'wasResultOf', '_:execution'); $variableBindings = $this->ConfigGraph->getAllProcessedVariableBindings(); foreach ($variableBindings as $name => $value) { $bindingBnode = '_:var_' . $name; $this->DataGraph->add_resource_triple('_:execution', API . 'variableBinding', $bindingBnode); $this->DataGraph->add_literal_triple($bindingBnode, API . 'name', $name); if (isset($value['type']) and $value['type'] == RDFS . 'Resource') { $this->DataGraph->add_resource_triple($bindingBnode, API . 'value', $value['value']); } else { if (isset($value['type'])) { $this->DataGraph->add_literal_triple($bindingBnode, API . 'value', $value['value'], null, $value['type']); } else { if (isset($value['lang'])) { $this->DataGraph->add_literal_triple($bindingBnode, API . 'value', $value['value'], $value['lang']); } else { $this->DataGraph->add_literal_triple($bindingBnode, API . 'value', $value['value']); } } } } $configFilters = $this->ConfigGraph->getAllFilters(); foreach ($configFilters as $filter) { $paramsArray = queryStringToParams($filter); foreach (array_keys($paramsArray) as $paramName) { $this->addTermBindingsToExecution($paramName); } } $uriFilters = $this->Request->getUnreservedParams(); foreach (array_keys($uriFilters) as $propertyPath) { $this->addTermBindingsToExecution($propertyPath); } $sort = $this->Request->getParam('_sort'); if (!$sort) { $sort = $this->ConfigGraph->getSort(); } if ($sort) { $sortPropPaths = explode(',', $sort); foreach ($sortPropPaths as $sortPropPath) { $sortPropPath = ltrim($sortPropPath, '-'); $this->addTermBindingsToExecution($sortPropPath); } } if ($requestProperties = $this->Request->getParam('_properties')) { foreach (explode(',', $requestProperties) as $propPath) { $this->addTermBindingsToExecution($propPath); } } if ($viewerProperties = $this->ConfigGraph->get_first_literal($this->getViewer(), API . 'properties')) { foreach (explode(',', $viewerProperties) as $propPath) { $this->addTermBindingsToExecution($propPath); } } }
function getGroupGraphPattern() { $whereRequestParam = $this->_request->getParam('_where'); $selectorConfigWhereProperty = $this->getConfigGraph()->getSelectWhere(); $bindings = $this->getConfigGraph()->getAllProcessedVariableBindings(); $selectorConfigWhereProperty = $this->fillQueryTemplate($selectorConfigWhereProperty, $bindings); if (!empty($whereRequestParam)) { $whereRequestParam = '{' . $whereRequestParam . '}'; } if (!empty($selectorConfigWhereProperty)) { $selectorConfigWhereProperty = '{' . $selectorConfigWhereProperty . '}'; } $GGP = "{$whereRequestParam}\n{$selectorConfigWhereProperty}\n "; $filter = implode('&', $this->getConfigGraph()->getAllFilters()); foreach ($this->_request->getUnreservedParams() as $k => $v) { list($k, $v) = array(urlencode($k), urlencode($v)); $filter .= "&{$k}={$v}"; } logDebug("Filter is: {$filter}"); $params = queryStringToParams($filter); $langs = array(); foreach ($params as $k => $v) { if (strpos($k, 'lang-') === 0) { $langs[substr($k, 5)] = $v; unset($params[$k]); } } $GGP .= $this->paramsToSparql($params, $langs); $GGP = trim($GGP); if (empty($GGP)) { $GGP = "\n ?item ?property ?value ."; } return $GGP; }
function hasUnknownPropertiesFromConfig($viewerUri = false) { if (!empty($this->_unknownPropertiesFromConfig)) { return true; } $filters = $this->getConfigGraph()->getAllFilters(); foreach ($filters as $filter) { $paramsArray = queryStringToParams($filter); foreach (array_keys($paramsArray) as $paramName) { $propertyNames = $this->paramNameToPropertyNames($paramName); $propertyNamesWithUris = $this->mapParamNameToProperties($paramName); foreach ($propertyNames as $pn) { if (empty($propertyNamesWithUris[$pn])) { $this->_unknownPropertiesFromConfig[] = $pn; } } } } $this->getOrderBy(); if ($viewerUri) { try { $chain = $this->getConfigGraph()->getViewerDisplayPropertiesValueAsPropertyChainArray($viewerUri); } catch (Exception $e) { $this->_unknownPropertiesFromConfig[] = $e->getMessage(); } } if (!empty($this->_unknownPropertiesFromConfig)) { return true; } return false; }