mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fix CS
This commit is contained in:
@@ -17,147 +17,142 @@
|
||||
*/
|
||||
class searchEngine_adapter
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_interface
|
||||
*/
|
||||
protected $search_engine;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_interface
|
||||
*/
|
||||
protected $search_engine;
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_options
|
||||
*/
|
||||
protected $search_options;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $first_page = false;
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_options
|
||||
*/
|
||||
protected $search_options;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param registryInterface $registry
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function __construct(registryInterface $registry)
|
||||
{
|
||||
if ($registry->get('GV_sphinx'))
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $first_page = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param registryInterface $registry
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function __construct(registryInterface $registry)
|
||||
{
|
||||
$this->search_engine = new searchEngine_adapter_sphinx_engine();
|
||||
}
|
||||
elseif (function_exists('phrasea_query2'))
|
||||
{
|
||||
$this->search_engine = new searchEngine_adapter_phrasea_engine();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('No search engine available, try phrasea2 or sphinx');
|
||||
if ($registry->get('GV_sphinx')) {
|
||||
$this->search_engine = new searchEngine_adapter_sphinx_engine();
|
||||
} elseif (function_exists('phrasea_query2')) {
|
||||
$this->search_engine = new searchEngine_adapter_phrasea_engine();
|
||||
} else {
|
||||
throw new Exception('No search engine available, try phrasea2 or sphinx');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param searchEngine_options $options
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function set_options(searchEngine_options $options)
|
||||
{
|
||||
$this->search_options = $options;
|
||||
$this->search_engine->set_options($options);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param searchEngine_options $options
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function set_options(searchEngine_options $options)
|
||||
{
|
||||
$this->search_options = $options;
|
||||
$this->search_engine->set_options($options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function set_is_first_page($boolean)
|
||||
{
|
||||
$this->first_page = ! ! $boolean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function set_is_first_page($boolean)
|
||||
{
|
||||
$this->first_page = !!$boolean;
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_first_page()
|
||||
{
|
||||
return $this->first_page;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_first_page()
|
||||
{
|
||||
return $this->first_page;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_query()
|
||||
{
|
||||
return $this->search_engine->get_parsed_query();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_query()
|
||||
{
|
||||
return $this->search_engine->get_parsed_query();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function reset_cache()
|
||||
{
|
||||
$this->search_engine->reset_cache();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return searchEngine_adapter
|
||||
*/
|
||||
public function reset_cache()
|
||||
{
|
||||
$this->search_engine->reset_cache();
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $page
|
||||
* @param int $perPage
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function query_per_page($query, $page, $perPage)
|
||||
{
|
||||
assert(is_int($page));
|
||||
assert($page > 0);
|
||||
assert(is_int($perPage));
|
||||
assert($perPage > 0);
|
||||
$offset = ($page - 1) * $perPage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $page
|
||||
* @param int $perPage
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function query_per_page($query, $page, $perPage)
|
||||
{
|
||||
assert(is_int($page));
|
||||
assert($page > 0);
|
||||
assert(is_int($perPage));
|
||||
assert($perPage > 0);
|
||||
$offset = ($page - 1) * $perPage;
|
||||
return $this->search_engine->results($query, $offset, $perPage);
|
||||
}
|
||||
|
||||
return $this->search_engine->results($query, $offset, $perPage);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $offset
|
||||
* @param int $perPage
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function query_per_offset($query, $offset, $perPage)
|
||||
{
|
||||
assert(is_int($offset));
|
||||
assert($offset >= 0);
|
||||
assert(is_int($perPage));
|
||||
assert($perPage > 0);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $query
|
||||
* @param int $offset
|
||||
* @param int $perPage
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function query_per_offset($query, $offset, $perPage)
|
||||
{
|
||||
assert(is_int($offset));
|
||||
assert($offset >= 0);
|
||||
assert(is_int($perPage));
|
||||
assert($perPage > 0);
|
||||
return $this->search_engine->results($query, $offset, $perPage);
|
||||
}
|
||||
|
||||
return $this->search_engine->results($query, $offset, $perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_status()
|
||||
{
|
||||
return $this->search_engine->get_status();
|
||||
}
|
||||
|
||||
public function build_excerpt($query, array $fields, record_adapter $record)
|
||||
{
|
||||
return $this->search_engine->build_excerpt($query, $fields, $record);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_status()
|
||||
{
|
||||
return $this->search_engine->get_status();
|
||||
}
|
||||
|
||||
public function build_excerpt($query, array $fields, record_adapter $record)
|
||||
{
|
||||
return $this->search_engine->build_excerpt($query, $fields, $record);
|
||||
}
|
||||
}
|
||||
|
@@ -17,174 +17,183 @@
|
||||
*/
|
||||
abstract class searchEngine_adapter_abstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $current_page;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $current_page;
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $total_results;
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $perPage;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $query;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $error = '';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $warning = '';
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $total_available;
|
||||
/**
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $total_time;
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offset_start;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $use_stemming = true;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $current_index = '';
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $total_results;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_available_results()
|
||||
{
|
||||
return $this->total_available;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $perPage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function get_time()
|
||||
{
|
||||
return $this->total_time;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $error = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_warning()
|
||||
{
|
||||
return $this->warning;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $warning = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_propositions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $total_available;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return searchEngine_adapter_abstract
|
||||
*/
|
||||
public function reset_cache()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $total_time;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_per_page()
|
||||
{
|
||||
return $this->perPage;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $offset_start;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_results()
|
||||
{
|
||||
return $this->total_results;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $use_stemming = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_pages()
|
||||
{
|
||||
return (int) ceil($this->get_available_results() / $this->get_per_page());
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_current_page()
|
||||
{
|
||||
return $this->current_page;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $current_index = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_offset_start()
|
||||
{
|
||||
return $this->offset_start;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_available_results()
|
||||
{
|
||||
return $this->total_available;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_current_indexes()
|
||||
{
|
||||
return $this->current_index;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function get_time()
|
||||
{
|
||||
return $this->total_time;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_error()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_warning()
|
||||
{
|
||||
return $this->warning;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_propositions()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return searchEngine_adapter_abstract
|
||||
*/
|
||||
public function reset_cache()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_per_page()
|
||||
{
|
||||
return $this->perPage;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_results()
|
||||
{
|
||||
return $this->total_results;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_pages()
|
||||
{
|
||||
return (int) ceil($this->get_available_results() / $this->get_per_page());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_current_page()
|
||||
{
|
||||
return $this->current_page;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_offset_start()
|
||||
{
|
||||
return $this->offset_start;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_current_indexes()
|
||||
{
|
||||
return $this->current_index;
|
||||
}
|
||||
}
|
||||
|
@@ -17,41 +17,42 @@
|
||||
*/
|
||||
interface searchEngine_adapter_interface
|
||||
{
|
||||
public function __construct();
|
||||
|
||||
public function set_options(searchEngine_options $options);
|
||||
public function __construct();
|
||||
|
||||
public function reset_cache();
|
||||
public function set_options(searchEngine_options $options);
|
||||
|
||||
public function get_time();
|
||||
public function reset_cache();
|
||||
|
||||
public function get_total_pages();
|
||||
public function get_time();
|
||||
|
||||
public function get_offset_start();
|
||||
public function get_total_pages();
|
||||
|
||||
public function get_current_page();
|
||||
public function get_offset_start();
|
||||
|
||||
public function get_per_page();
|
||||
public function get_current_page();
|
||||
|
||||
public function get_total_results();
|
||||
public function get_per_page();
|
||||
|
||||
public function get_available_results();
|
||||
public function get_total_results();
|
||||
|
||||
public function get_propositions();
|
||||
public function get_available_results();
|
||||
|
||||
public function get_parsed_query();
|
||||
public function get_propositions();
|
||||
|
||||
public function get_suggestions(Session_Handler $session);
|
||||
public function get_parsed_query();
|
||||
|
||||
public function get_error();
|
||||
public function get_suggestions(Session_Handler $session);
|
||||
|
||||
public function get_warning();
|
||||
public function get_error();
|
||||
|
||||
public function get_current_indexes();
|
||||
public function get_warning();
|
||||
|
||||
public function get_status();
|
||||
public function get_current_indexes();
|
||||
|
||||
public function results($query, $page, $perPage);
|
||||
public function get_status();
|
||||
|
||||
public function build_excerpt($query, array $fields, record_adapter $record);
|
||||
public function results($query, $page, $perPage);
|
||||
|
||||
public function build_excerpt($query, array $fields, record_adapter $record);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,466 +17,448 @@
|
||||
*/
|
||||
class searchEngine_options implements Serializable
|
||||
{
|
||||
const RECORD_RECORD = 0;
|
||||
const RECORD_GROUPING = 1;
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_VIDEO = 'video';
|
||||
const TYPE_AUDIO = 'audio';
|
||||
const TYPE_DOCUMENT = 'document';
|
||||
const TYPE_FLASH = 'flash';
|
||||
const TYPE_ALL = '';
|
||||
const SORT_RELEVANCE = 'relevance';
|
||||
const SORT_CREATED_ON = 'created_on';
|
||||
const SORT_RANDOM = 'random';
|
||||
const SORT_MODE_ASC = 'asc';
|
||||
const SORT_MODE_DESC = 'desc';
|
||||
|
||||
const RECORD_RECORD = 0;
|
||||
const RECORD_GROUPING = 1;
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_VIDEO = 'video';
|
||||
const TYPE_AUDIO = 'audio';
|
||||
const TYPE_DOCUMENT = 'document';
|
||||
const TYPE_FLASH = 'flash';
|
||||
const TYPE_ALL = '';
|
||||
const SORT_RELEVANCE = 'relevance';
|
||||
const SORT_CREATED_ON = 'created_on';
|
||||
const SORT_RANDOM = 'random';
|
||||
const SORT_MODE_ASC = 'asc';
|
||||
const SORT_MODE_DESC = 'desc';
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $record_type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $record_type;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $search_type = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $search_type = 0;
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bases = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bases = array();
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fields = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fields = array();
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $status = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $status = array();
|
||||
/**
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $date_min;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $date_min;
|
||||
/**
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $date_max;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $date_max;
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $date_fields = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $date_fields = array();
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $i18n;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $i18n;
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $stemming = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $stemming = true;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sort_by = self::SORT_CREATED_ON;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sort_by = self::SORT_CREATED_ON;
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sort_ord = self::SORT_MODE_DESC;
|
||||
protected $business_fields = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sort_ord = self::SORT_MODE_DESC;
|
||||
protected $business_fields = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $locale
|
||||
*/
|
||||
public function set_locale($locale)
|
||||
{
|
||||
$this->i18n = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_locale()
|
||||
{
|
||||
return $this->i18n;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param const $sort_by
|
||||
* @param const $sort_ord
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_sort($sort_by, $sort_ord = self::SORT_MODE_DESC)
|
||||
{
|
||||
$this->sort_by = $sort_by;
|
||||
$this->sort_ord = $sort_ord;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_business_fields(Array $base_ids)
|
||||
{
|
||||
$this->business_fields = $base_ids;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_business_fields()
|
||||
{
|
||||
return $this->business_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sortby()
|
||||
{
|
||||
return $this->sort_by;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sortord()
|
||||
{
|
||||
return $this->sort_ord;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_use_stemming($boolean)
|
||||
{
|
||||
$this->stemming = ! ! $boolean;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function get_use_stemming()
|
||||
{
|
||||
return $this->stemming;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $search_type
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_search_type($search_type)
|
||||
{
|
||||
switch ($search_type)
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
case self::RECORD_RECORD:
|
||||
default:
|
||||
$this->search_type = self::RECORD_RECORD;
|
||||
break;
|
||||
case self::RECORD_GROUPING:
|
||||
$this->search_type = self::RECORD_GROUPING;
|
||||
break;
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_search_type()
|
||||
{
|
||||
return $this->search_type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $base_ids
|
||||
* @param ACL $ACL
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_bases(Array $base_ids, ACL $ACL)
|
||||
{
|
||||
foreach ($base_ids as $base_id)
|
||||
/**
|
||||
*
|
||||
* @param string $locale
|
||||
*/
|
||||
public function set_locale($locale)
|
||||
{
|
||||
if ($ACL->has_access_to_base($base_id))
|
||||
$this->bases[$base_id] = $base_id;
|
||||
$this->i18n = $locale;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_bases()
|
||||
{
|
||||
return $this->bases;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_fields(Array $fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $status
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_status(Array $status)
|
||||
{
|
||||
$tmp = array();
|
||||
foreach ($status as $n => $options)
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_locale()
|
||||
{
|
||||
if (count($options) > 1)
|
||||
continue;
|
||||
if (isset($options['on']))
|
||||
{
|
||||
foreach ($options['on'] as $sbas_id)
|
||||
$tmp[$n][$sbas_id] = 1;
|
||||
}
|
||||
if (isset($options['off']))
|
||||
{
|
||||
foreach ($options['off'] as $sbas_id)
|
||||
$tmp[$n][$sbas_id] = 0;
|
||||
}
|
||||
return $this->i18n;
|
||||
}
|
||||
|
||||
$this->status = $tmp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_status()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $record_type
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_record_type($record_type)
|
||||
{
|
||||
switch ($record_type)
|
||||
/**
|
||||
*
|
||||
* @param const $sort_by
|
||||
* @param const $sort_ord
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_sort($sort_by, $sort_ord = self::SORT_MODE_DESC)
|
||||
{
|
||||
case self::TYPE_ALL:
|
||||
default:
|
||||
$this->record_type = self::TYPE_ALL;
|
||||
break;
|
||||
case self::TYPE_AUDIO:
|
||||
$this->record_type = self::TYPE_AUDIO;
|
||||
break;
|
||||
case self::TYPE_VIDEO:
|
||||
$this->record_type = self::TYPE_VIDEO;
|
||||
break;
|
||||
case self::TYPE_DOCUMENT:
|
||||
$this->record_type = self::TYPE_DOCUMENT;
|
||||
break;
|
||||
case self::TYPE_FLASH:
|
||||
$this->record_type = self::TYPE_FLASH;
|
||||
break;
|
||||
case self::TYPE_IMAGE:
|
||||
$this->record_type = self::TYPE_IMAGE;
|
||||
break;
|
||||
$this->sort_by = $sort_by;
|
||||
$this->sort_ord = $sort_ord;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_record_type()
|
||||
{
|
||||
return $this->record_type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $min_date
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_min_date($min_date)
|
||||
{
|
||||
if ( ! is_null($min_date) && trim($min_date) !== '')
|
||||
public function set_business_fields(Array $base_ids)
|
||||
{
|
||||
$this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date . ' 00:00:00');
|
||||
$this->business_fields = $base_ids;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function get_min_date()
|
||||
{
|
||||
return $this->date_min;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $max_date
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_max_date($max_date)
|
||||
{
|
||||
if ( ! is_null($max_date) && trim($max_date) !== '')
|
||||
public function get_business_fields()
|
||||
{
|
||||
$this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date . ' 23:59:59');
|
||||
return $this->business_fields;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function get_max_date()
|
||||
{
|
||||
return $this->date_max;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_date_fields(Array $fields)
|
||||
{
|
||||
$this->date_fields = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_date_fields()
|
||||
{
|
||||
return $this->date_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($this as $key => $value)
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sortby()
|
||||
{
|
||||
if ($value instanceof DateTime)
|
||||
$value = $value->format('d-m-Y h:i:s');
|
||||
|
||||
$ret[$key] = $value;
|
||||
return $this->sort_by;
|
||||
}
|
||||
|
||||
return p4string::jsonencode($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $serialized
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$serialized = json_decode($serialized);
|
||||
|
||||
foreach ($serialized as $key => $value)
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_sortord()
|
||||
{
|
||||
if (is_null($value))
|
||||
{
|
||||
$value = null;
|
||||
}
|
||||
elseif (in_array($key, array('date_min', 'date_max')))
|
||||
{
|
||||
$value = new DateTime($value);
|
||||
}
|
||||
elseif ($value instanceof stdClass)
|
||||
{
|
||||
$tmpvalue = (array) $value;
|
||||
$value = array();
|
||||
return $this->sort_ord;
|
||||
}
|
||||
|
||||
foreach ($tmpvalue as $k => $data)
|
||||
{
|
||||
$k = ctype_digit($k) ? (int) $k : $k;
|
||||
$value[$k] = $data;
|
||||
/**
|
||||
*
|
||||
* @param boolean $boolean
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_use_stemming($boolean)
|
||||
{
|
||||
$this->stemming = ! ! $boolean;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function get_use_stemming()
|
||||
{
|
||||
return $this->stemming;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $search_type
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_search_type($search_type)
|
||||
{
|
||||
switch ($search_type) {
|
||||
case self::RECORD_RECORD:
|
||||
default:
|
||||
$this->search_type = self::RECORD_RECORD;
|
||||
break;
|
||||
case self::RECORD_GROUPING:
|
||||
$this->search_type = self::RECORD_GROUPING;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_search_type()
|
||||
{
|
||||
return $this->search_type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $base_ids
|
||||
* @param ACL $ACL
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_bases(Array $base_ids, ACL $ACL)
|
||||
{
|
||||
foreach ($base_ids as $base_id) {
|
||||
if ($ACL->has_access_to_base($base_id))
|
||||
$this->bases[$base_id] = $base_id;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_bases()
|
||||
{
|
||||
return $this->bases;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_fields(Array $fields)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $status
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_status(Array $status)
|
||||
{
|
||||
$tmp = array();
|
||||
foreach ($status as $n => $options) {
|
||||
if (count($options) > 1)
|
||||
continue;
|
||||
if (isset($options['on'])) {
|
||||
foreach ($options['on'] as $sbas_id)
|
||||
$tmp[$n][$sbas_id] = 1;
|
||||
}
|
||||
if (isset($options['off'])) {
|
||||
foreach ($options['off'] as $sbas_id)
|
||||
$tmp[$n][$sbas_id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$this->status = $tmp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_status()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $record_type
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_record_type($record_type)
|
||||
{
|
||||
switch ($record_type) {
|
||||
case self::TYPE_ALL:
|
||||
default:
|
||||
$this->record_type = self::TYPE_ALL;
|
||||
break;
|
||||
case self::TYPE_AUDIO:
|
||||
$this->record_type = self::TYPE_AUDIO;
|
||||
break;
|
||||
case self::TYPE_VIDEO:
|
||||
$this->record_type = self::TYPE_VIDEO;
|
||||
break;
|
||||
case self::TYPE_DOCUMENT:
|
||||
$this->record_type = self::TYPE_DOCUMENT;
|
||||
break;
|
||||
case self::TYPE_FLASH:
|
||||
$this->record_type = self::TYPE_FLASH;
|
||||
break;
|
||||
case self::TYPE_IMAGE:
|
||||
$this->record_type = self::TYPE_IMAGE;
|
||||
break;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_record_type()
|
||||
{
|
||||
return $this->record_type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $min_date
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_min_date($min_date)
|
||||
{
|
||||
if ( ! is_null($min_date) && trim($min_date) !== '') {
|
||||
$this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date . ' 00:00:00');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function get_min_date()
|
||||
{
|
||||
return $this->date_min;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $max_date
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_max_date($max_date)
|
||||
{
|
||||
if ( ! is_null($max_date) && trim($max_date) !== '') {
|
||||
$this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date . ' 23:59:59');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function get_max_date()
|
||||
{
|
||||
return $this->date_max;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function set_date_fields(Array $fields)
|
||||
{
|
||||
$this->date_fields = $fields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_date_fields()
|
||||
{
|
||||
return $this->date_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
$ret = array();
|
||||
foreach ($this as $key => $value) {
|
||||
if ($value instanceof DateTime)
|
||||
$value = $value->format('d-m-Y h:i:s');
|
||||
|
||||
$ret[$key] = $value;
|
||||
}
|
||||
|
||||
return p4string::jsonencode($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $serialized
|
||||
* @return searchEngine_options
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$serialized = json_decode($serialized);
|
||||
|
||||
foreach ($serialized as $key => $value) {
|
||||
if (is_null($value)) {
|
||||
$value = null;
|
||||
} elseif (in_array($key, array('date_min', 'date_max'))) {
|
||||
$value = new DateTime($value);
|
||||
} elseif ($value instanceof stdClass) {
|
||||
$tmpvalue = (array) $value;
|
||||
$value = array();
|
||||
|
||||
foreach ($tmpvalue as $k => $data) {
|
||||
$k = ctype_digit($k) ? (int) $k : $k;
|
||||
$value[$k] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -17,132 +17,131 @@
|
||||
*/
|
||||
class searchEngine_results
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var set
|
||||
*/
|
||||
protected $result;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var set
|
||||
*/
|
||||
protected $result;
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_interface
|
||||
*/
|
||||
protected $engine;
|
||||
/**
|
||||
*
|
||||
* @var searchEngine_adapter_interface
|
||||
*/
|
||||
protected $engine;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param set $result
|
||||
* @param searchEngine_adapter_interface $engine
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function __construct(set_abstract $result, searchEngine_adapter_interface $engine)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->result = $result;
|
||||
/**
|
||||
*
|
||||
* @param set $result
|
||||
* @param searchEngine_adapter_interface $engine
|
||||
* @return searchEngine_results
|
||||
*/
|
||||
public function __construct(set_abstract $result, searchEngine_adapter_interface $engine)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->result = $result;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return set
|
||||
*/
|
||||
public function get_datas()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return set
|
||||
*/
|
||||
public function get_datas()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function get_query_time()
|
||||
{
|
||||
return $this->engine->get_time();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function get_query_time()
|
||||
{
|
||||
return $this->engine->get_time();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_pages()
|
||||
{
|
||||
return $this->engine->get_total_pages();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_total_pages()
|
||||
{
|
||||
return $this->engine->get_total_pages();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_current_page()
|
||||
{
|
||||
return (int) $this->engine->get_current_page();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_current_page()
|
||||
{
|
||||
return (int) $this->engine->get_current_page();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count_available_results()
|
||||
{
|
||||
return (int) $this->engine->get_available_results();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count_available_results()
|
||||
{
|
||||
return (int) $this->engine->get_available_results();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count_total_results()
|
||||
{
|
||||
return (int) $this->engine->get_total_results();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_count_total_results()
|
||||
{
|
||||
return (int) $this->engine->get_total_results();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_error()
|
||||
{
|
||||
return $this->engine->get_error();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_error()
|
||||
{
|
||||
return $this->engine->get_error();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_warning()
|
||||
{
|
||||
return $this->engine->get_warning();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_warning()
|
||||
{
|
||||
return $this->engine->get_warning();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_suggestions()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$session = $appbox->get_session();
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_suggestions()
|
||||
{
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$session = $appbox->get_session();
|
||||
|
||||
return $this->engine->get_suggestions($session);
|
||||
}
|
||||
return $this->engine->get_suggestions($session);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_propositions()
|
||||
{
|
||||
return $this->engine->get_propositions();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_search_indexes()
|
||||
{
|
||||
return $this->engine->get_current_indexes();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_propositions()
|
||||
{
|
||||
return $this->engine->get_propositions();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_search_indexes()
|
||||
{
|
||||
return $this->engine->get_current_indexes();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user