protected function _buildQuery($setup, $forImplicit = false) { if (isset($setup->config->query->deeper) && isset($setup->state->parent)) { //$replace = ; $queryString = str_replace("%resource%", $setup->state->parent, $setup->config->query->deeper); $query = Erfurt_Sparql_SimpleQuery::initWithString($queryString); } else { $query = new Erfurt_Sparql_Query2(); $query->addElements(NavigationHelper::getSearchTriples($setup, $forImplicit, $this->_config->store->backend)); //$query->setCountStar(true); $query->setDistinct(true); $query->addProjectionVar(new Erfurt_Sparql_Query2_Var('resourceUri')); //$query->addProjectionVar(new Erfurt_Sparql_Query2_Var('subResourceUri')); // set to _limit+1, so we can see if there are more than $_limit entries //$query->setLimit($this->_limit + 1); } // sorting if (isset($setup->state->sorting)) { $query->getOrder()->add(new Erfurt_Sparql_Query2_Var('sortRes'), "ASC"); } elseif (isset($setup->config->ordering->relation)) { // set ordering $orderVar = new Erfurt_Sparql_Query2_Var('order'); $query->getWhere()->addElement(new Erfurt_Sparql_Query2_OptionalGraphPattern(array(new Erfurt_Sparql_Query2_Triple(new Erfurt_Sparql_Query2_Var('resourceUri'), new Erfurt_Sparql_Query2_IriRef($setup->config->ordering->relation), $orderVar)))); $query->getOrder()->add($orderVar, $setup->config->ordering->modifier); } // set offset if (isset($setup->state->offset) && $setup->state->lastEvent == 'more') { $query->setLimit($this->_limit + $setup->state->offset + 1); } else { $query->setLimit($this->_limit + 1); } return $query; }