/** */ public function getBasePath() { $basePath = $this->getRequest()->getBasePath(); $uri = new \Zend\Uri\Uri($this->getRequest()->getUri()); $uri->setPath($basePath); $uri->setQuery(array()); $uri->setFragment(''); return $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath(); }
public function basePath() { $basePath = $this->getRequest()->getBasePath(); $uri = new \Zend\Uri\Uri($this->getRequest()->getUri()); $uri->setPath($basePath); $uri->setQuery(array()); $uri->setFragment(''); return $uri->getScheme() . '://' . $uri->getHost() . '' . $uri->getPath(); //Sample output http://localhost/zend/public }
/** * Get the base URI for the current controller * * @return string */ protected function getBackendUrl(ServiceLocatorInterface $sl) { $router = $sl->get('router'); $route = $router->assemble(array(), array('name' => 'hybridauth/backend')); $request = $sl->get('request'); $basePath = $request->getBasePath(); $uri = new \Zend\Uri\Uri($request->getUri()); $uri->setPath($basePath); $uri->setQuery(array()); $uri->setFragment(''); return $uri->getScheme() . '://' . $uri->getHost() . preg_replace('/[\\/]+/', '/', $uri->getPath() . '/' . $route); }
/** * Retrieve recommendations for results in other tabs * * @return \Zend\Http\Response */ public function getSearchTabsRecommendationsAjax() { $this->disableSessionWrites(); // avoid session write timing bug $config = $this->getServiceLocator()->get('VuFind\\Config')->get('config'); if (empty($config->SearchTabsRecommendations->recommendations)) { return $this->output('', self::STATUS_OK); } $id = $this->params()->fromPost('searchId', $this->params()->fromQuery('searchId')); $limit = $this->params()->fromPost('limit', $this->params()->fromQuery('limit', null)); $table = $this->getServiceLocator()->get('VuFind\\DbTablePluginManager'); $search = $table->get('Search')->select(['id' => $id])->current(); if (empty($search)) { return $this->output('Search not found', self::STATUS_ERROR, 400); } $minSO = $search->getSearchObject(); $results = $this->getServiceLocator()->get('VuFind\\SearchResultsPluginManager'); $savedSearch = $minSO->deminify($results); $params = $savedSearch->getParams(); $query = $params->getQuery(); if (!$query instanceof \VuFindSearch\Query\Query) { return $this->output('', self::STATUS_OK); } $lookfor = $query->getString(); if (!$lookfor) { return $this->output('', self::STATUS_OK); } $searchClass = $params->getSearchClassId(); // Don't return recommendations if not configured or for combined view // or for search types other than basic search. if (empty($config->SearchTabsRecommendations->recommendations[$searchClass]) || $searchClass == 'Combined' || $params->getSearchType() != 'basic') { return $this->output('', self::STATUS_OK); } $view = $this->getViewRenderer(); $view->results = $savedSearch; $searchTabsHelper = $this->getViewRenderer()->plugin('searchtabs'); $searchTabsHelper->setView($view); $tabs = $searchTabsHelper->getTabConfig($searchClass, $lookfor, $params->getQuery()->getHandler()); $html = ''; $recommendations = array_map('trim', explode(',', $config->SearchTabsRecommendations->recommendations[$searchClass])); foreach ($recommendations as $recommendation) { if ($searchClass == $recommendation) { // Who would want this? continue; } foreach ($tabs as $tab) { if ($tab['id'] == $recommendation) { $uri = new \Zend\Uri\Uri($tab['url']); $runner = $this->getServiceLocator()->get('VuFind\\SearchRunner'); $otherResults = $runner->run($uri->getQueryAsArray(), $tab['class'], function ($runner, $params, $searchId) use($config) { $params->setLimit(isset($config->SearchTabsRecommendations->count) ? $config->SearchTabsRecommendations->count : 2); $params->setPage(1); $params->resetFacetConfig(); $options = $params->getOptions(); $options->disableHighlighting(); }); if ($otherResults instanceof \VuFind\Search\EmptySet\Results) { continue; } if (null !== $limit) { $tab['url'] .= '&limit=' . urlencode($limit); } $html .= $this->getViewRenderer()->partial('Recommend/SearchTabs.phtml', ['tab' => $tab, 'lookfor' => $lookfor, 'handler' => $params->getQuery()->getHandler(), 'results' => $otherResults]); } } } return $this->output($html, self::STATUS_OK); }