/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/Simple.php
* @author chabior
*/
class Simple implements StrategyInterface
{
/**
* @param array|\Elastica\Connection[] $connections
*
* @throws \Elastica\Exception\ClientException
*
* @return \Elastica\Connection
*/
public function getConnection($connections)
{
foreach ($connections as $connection) {
if ($connection->isEnabled()) {
return $connection;
}
}
throw new ClientException('No enabled connection');
}
}
Arguments
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php
return false;
}
/**
* @return array
*/
public function getConnections()
{
return $this->_connections;
}
/**
* @throws \Elastica\Exception\ClientException
*
* @return \Elastica\Connection
*/
public function getConnection()
{
return $this->_strategy->getConnection($this->getConnections());
}
/**
* @param \Elastica\Connection $connection
* @param \Exception $e
* @param Client $client
*/
public function onFail(Connection $connection, Exception $e, Client $client)
{
$connection->setEnabled(false);
if ($this->_callback) {
call_user_func($this->_callback, $connection, $e, $client);
}
}
/**
* @return \Elastica\Connection\Strategy\StrategyInterface
*/
public function getStrategy()
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/vendor/ruflin/elastica/lib/Elastica/Client.php
}
/**
* Determines whether a valid connection is available for use.
*
* @return bool
*/
public function hasConnection()
{
return $this->_connectionPool->hasConnection();
}
/**
* @throws \Elastica\Exception\ClientException
*
* @return \Elastica\Connection
*/
public function getConnection()
{
return $this->_connectionPool->getConnection();
}
/**
* @return \Elastica\Connection[]
*/
public function getConnections()
{
return $this->_connectionPool->getConnections();
}
/**
* @return \Elastica\Connection\Strategy\StrategyInterface
*/
public function getConnectionStrategy()
{
return $this->_connectionPool->getStrategy();
}
/**
* @param array|\Elastica\Connection[] $connections
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/vendor/ruflin/elastica/lib/Elastica/Client.php
}
/**
* Makes calls to the elasticsearch server based on this index.
*
* It's possible to make any REST query directly over this method
*
* @param string $path Path to call
* @param string $method Rest method to use (GET, POST, DELETE, PUT)
* @param array|string $data OPTIONAL Arguments as array or pre-encoded string
* @param array $query OPTIONAL Query params
* @param string $contentType Content-Type sent with this request
*
* @throws Exception\ConnectionException|\Exception
*
* @return Response Response object
*/
public function request($path, $method = Request::GET, $data = [], array $query = [], $contentType = Request::DEFAULT_CONTENT_TYPE)
{
$connection = $this->getConnection();
$request = $this->_lastRequest = new Request($path, $method, $data, $query, $connection, $contentType);
$this->_lastResponse = null;
try {
$response = $this->_lastResponse = $request->send();
} catch (ConnectionException $e) {
$this->_connectionPool->onFail($connection, $e, $this);
$this->_log($e);
// In case there is no valid connection left, throw exception which caused the disabling of the connection.
if (!$this->hasConnection()) {
throw $e;
}
return $this->request($path, $method, $data, $query);
}
$this->_log($request);
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/vendor/ruflin/elastica/lib/Elastica/Search.php
* @return \Elastica\ResultSet
*/
public function search($query = '', $options = null)
{
$this->setOptionsAndQuery($options, $query);
$query = $this->getQuery();
$path = $this->getPath();
$params = $this->getOptions();
// Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids.
if ('_search/scroll' == $path) {
$data = [self::OPTION_SCROLL_ID => $params[self::OPTION_SCROLL_ID]];
unset($params[self::OPTION_SCROLL_ID]);
} else {
$data = $query->toArray();
}
$response = $this->getClient()->request(
$path,
Request::GET,
$data,
$params
);
return $this->_builder->buildResultSet($response, $query);
}
/**
* @param mixed $query
* @param $fullResult (default = false) By default only the total hit count is returned. If set to true, the full ResultSet including aggregations is returned
*
* @return int|ResultSet
*/
public function count($query = '', $fullResult = false)
{
$this->setOptionsAndQuery(null, $query);
// Clone the object as we do not want to modify the original query.
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/classes/engines/elastica/class-wpsolr-searchelasticaclient.php
/**
* Execute an update query with the client.
*
* @param \Elastica\Client $search_engine_client
* @param \Elastica\Search $query
*
* @return WPSOLR_ResultsElasticaClient
*/
public function search_engine_client_execute( $search_engine_client, $query ) {
$this->search_engine_client_build_query();
$search = new \Elastica\Search( $this->search_engine_client );
$search->addIndex( $this->get_elastica_index() );
$search->addType( $this->get_elastica_type() );
$the_query = isset( $this->completion ) ? $this->completion : $this->query;
$search->setQuery( $the_query );
return new WPSOLR_ResultsElasticaClient( $search->search() );
}
/**
* Build the query.
*
*/
public function search_engine_client_build_query() {
if ( $this->is_query_built ) {
// Already done.
return;
}
$this->is_query_built = true;
if ( ! isset( $this->completion ) ) {
// Normal search.
if ( $this->is_did_you_mean ) {
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/classes/engines/class-wpsolr-abstractsearchclient.php
} else {
// Could not fix it.
throw $e;
}
}
}
}
/**
* Execute a query.
* Used internally, or when fine tuned select query is better than using a WPSOLR query.
*
* @return WPSOLR_AbstractResultsClient
*/
public function execute_query() {
// Perform the query, return the result set
return $this->results = $this->search_engine_client_execute( $this->search_engine_client, $this->query_select );
}
/**
* Get suggestions for did you mean.
*
* @param string $keywords
*
* @return string Did you mean keyword
*/
abstract protected function search_engine_client_get_did_you_mean_suggestions( $keywords );
/**
*
* @param WPSOLR_Query $wpsolr_query
*
* @return array Array of html
*/
public function display_results( WPSOLR_Query $wpsolr_query ) {
/home/hplex/live/sources/plugins/wpsolr-search-engine/wpsolr/core/classes/engines/class-wpsolr-abstractsearchclient.php
*
* @return WPSOLR_AbstractResultsClient
*/
public function execute_wpsolr_query( WPSOLR_Query $wpsolr_query, $is_use_cache = true ) {
if ( $is_use_cache && isset( $this->results ) ) {
// Return results already in cache
return $this->results;
}
// Perform the query, return the result set
$max_trials = 2;
for ( $i = 1; $i <= $max_trials; $i ++ ) {
try {
// (re) Create the query from the wpsolr query
$this->set_query_select( $wpsolr_query );
// Perform the query, return the result set
return $this->execute_query();
} catch ( \Exception $e ) {
if ( $i < $max_trials ) {
// Fix the issue, eventually
$this->search_engine_client_execute_fix_error( $e, $this->search_engine_client, $this->query_select );
} else {
// Could not fix it.
throw $e;
}
}
}
}
/**
* Execute a query.
* Used internally, or when fine tuned select query is better than using a WPSOLR query.
/home/hplex/live/wp-content/themes/lexicon/lib/Search.php
GROUP BY p.ID
ORDER BY IF(p.post_type = 'post',0,1) DESC"
);
if ($results) {
$result = array_shift($results);
$class = singleContentType($result->post_type);
$this->exactMatch = new $class($result->ID);
$this->exactMatch->tease_class .= ' exact-match';
} else {
$this->exactMatch = 'none';
}
return ($this->exactMatch == 'none')?false:$this->exactMatch;
}
public function getResults()
{
$this->resultSet = $this->solrClient->execute_wpsolr_query($this->query);
$this->found = $this->resultSet->get_nb_results();
$this->documents = $this->resultSet->get_results();
if ($this->found) {
$this->facetSet = $this->documents->getFacetSet();
}
}
public function numFound()
{
return $this->found;
}
public function results()
{
$results = [];
$exact = $this->getExactMatch();
if ($exact) {
$results[$exact->id] = $exact;
}
/home/hplex/live/wp-content/themes/lexicon/lib/Search.php
'icon_str' => 'Icon',
'tags' => 'Tags',
'hplex_alphasort_chr_str' => 'By Letter',
'list_str' => 'On List',
'gender_str' => 'Gender'
];
public function __construct()
{
$this->query = WPSOLR_Service_Container::get_query();
$this->searchTerms = $this->query->get_wpsolr_query();
$this->cleanedSearchTerms = removeCommonWords($this->searchTerms);
if ($this->searchTerms != $this->cleanedSearchTerms) {
$this->query->set_wpsolr_query($this->cleanedSearchTerms);
}
$this->displayFacets = WPSOLR_Service_Container::getOption()->get_facets_to_display();
$this->solrClient = WPSOLR_Service_Container::get_solr_client();
$this->getResults();
$this->urlParts['wpsolr_q'] = $this->searchTerms;
if (isset($_REQUEST['wpsolr_fq'])) {
$fq = array_unique($_REQUEST['wpsolr_fq']);
sort($fq);
$this->urlParts['wpsolr_fq'] = $fq;
}
}
public function link($replace = [])
{
$parts = $this->urlParts;
foreach ($replace as $key => $value) {
$parts[$key] = $value;
}
return $this->baseUrl . http_build_query($parts);
}
public function getExactMatch()
{
/home/hplex/live/wp-content/themes/lexicon/page-19634.php
$fq = array_unique($_REQUEST['wpsolr_fq']);
sort($fq);
$context['url_parts']['wpsolr_fq'] = $fq;
$context['next_facetid'] = urlencode("wpsolr_fq[" . count($fq) . "]");
}
$context['base_link'] = "/search-wpsolr/?" . http_build_query($context['url_parts']);
if (isset($_REQUEST['wpsolr_fq'])) {
if ($fq != $_REQUEST['wpsolr_fq']) {
wp_redirect($context['base_link'], 302);
}
}
require_once("lib/Search.php");
//ini_set('display_errors', 'On');
$search = new \Lexicon\Search();
$context['exact_match'] = $search->getExactMatch();
$context['count'] = $search->numFound();
$context['page'] = (isset($_REQUEST['wpsolr_page']))?$_REQUEST['wpsolr_page']:1;
$context['pages'] = ceil($context['count'] / 25);
if ($context['page'] > 1) {
$prevq = $context['url_parts'];
$prevq['wpsolr_page'] = $context['page'] - 1;
$context['pagination_prev'] = '/search-wpsolr/?' . http_build_query($prevq);
}
if ($context['page'] < $context['pages']) {
$nextq = $context['url_parts'];
$nextq['wpsolr_page'] = $context['page'] + 1;
$context['pagination_next'] = '/search-wpsolr/?' . http_build_query($nextq);
}
$context['pagination_start'] = ($context['page'] > 6) ? $context['page'] - 3 : 2;
/home/hplex/live/www/wp-includes/template-loader.php
*/
$template = apply_filters( 'template_include', $template );
$is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
$template = $is_stringy ? realpath( (string) $template ) : null;
if (
is_string( $template ) &&
( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&
is_file( $template ) &&
is_readable( $template )
) {
/**
* Fires immediately before including the template.
*
* @since 6.9.0
*
* @param string $template The path of the template about to be included.
*/
do_action( 'wp_before_include_template', $template );
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
Arguments
"/home/hplex/live/wp-content/themes/lexicon/page-19634.php"
/home/hplex/live/www/wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
Arguments
"/home/hplex/live/www/wp-includes/template-loader.php"
/home/hplex/live/www/index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
Arguments
"/home/hplex/live/www/wp-blog-header.php"