mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
[SearchEngine] Update API monitor
This commit is contained in:
@@ -47,6 +47,14 @@ class PhraseaEngine implements SearchEngineInterface
|
|||||||
$this->options = new SearchEngineOptions();
|
$this->options = new SearchEngineOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'Phrasea';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@@ -22,6 +22,13 @@ interface SearchEngineInterface
|
|||||||
const GEM_TYPE_STORY = 'story';
|
const GEM_TYPE_STORY = 'story';
|
||||||
const GEM_TYPE_ENTRY = 'entry';
|
const GEM_TYPE_ENTRY = 'entry';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the search engine
|
||||||
|
*
|
||||||
|
* @return string The name of the search-engine
|
||||||
|
*/
|
||||||
|
public function getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the status of the search engine
|
* Check the status of the search engine
|
||||||
*
|
*
|
||||||
|
@@ -71,6 +71,14 @@ class SphinxSearchEngine implements SearchEngineInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return 'SphinxSearch';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@@ -324,6 +324,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
*/
|
*/
|
||||||
protected function get_gv_info(Application $app)
|
protected function get_gv_info(Application $app)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
$SEStatus = $app['phraseanet.SE']->status();
|
||||||
|
} catch (\RuntimeException $e) {
|
||||||
|
$SEStatus = array('error' => $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'global_values' => array(
|
'global_values' => array(
|
||||||
'serverName' => $app['phraseanet.registry']->get('GV_ServerName'),
|
'serverName' => $app['phraseanet.registry']->get('GV_ServerName'),
|
||||||
@@ -405,20 +411,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'configuration' => array(
|
'configuration' => array(
|
||||||
'defaultQuery' => $app['phraseanet.registry']->get('GV_defaultQuery'),
|
'defaultQuery' => $app['phraseanet.registry']->get('GV_defaultQuery'),
|
||||||
'defaultQueryType' => $app['phraseanet.registry']->get('GV_defaultQuery_type'),
|
'defaultQueryType' => $app['phraseanet.registry']->get('GV_defaultQuery_type'),
|
||||||
|
'minChar' => $app['phraseanet.registry']->get('GV_min_letters_truncation'),
|
||||||
|
'sort' => $app['phraseanet.registry']->get('GV_phrasea_sort'),
|
||||||
),
|
),
|
||||||
/**
|
'engine' => array(
|
||||||
* @todo neutron update this
|
'type' => $app['phraseanet.SE']->getName(),
|
||||||
*/
|
'status' => $SEStatus,
|
||||||
'sphinx' => array(
|
'configuration' => $app['phraseanet.SE']->configurationPanel()->getConfiguration(),
|
||||||
'active' => $app['phraseanet.registry']->get('GV_sphinx'),
|
|
||||||
'host' => $app['phraseanet.registry']->get('GV_sphinx_host'),
|
|
||||||
'port' => $app['phraseanet.registry']->get('GV_sphinx_port'),
|
|
||||||
'realtimeHost' => $app['phraseanet.registry']->get('GV_sphinx_rt_host'),
|
|
||||||
'realtimePort' => $app['phraseanet.registry']->get('GV_sphinx_rt_port'),
|
|
||||||
),
|
|
||||||
'phrasea' => array(
|
|
||||||
'minChar' => $app['phraseanet.registry']->get('GV_min_letters_truncation'),
|
|
||||||
'sort' => $app['phraseanet.registry']->get('GV_phrasea_sort'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'binary' => array(
|
'binary' => array(
|
||||||
@@ -499,7 +498,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($app['request'], $this);
|
$result = new API_V1_result($app['request'], $this);
|
||||||
|
|
||||||
$ret = array_merge(
|
$ret = array_merge(
|
||||||
$this->get_config_info($app), $this->get_cache_info($app), $this->get_gv_info($app)
|
$this->get_config_info($app), $this->get_cache_info($app), $this->get_gv_info($app)
|
||||||
);
|
);
|
||||||
|
|
||||||
$result->set_datas($ret);
|
$result->set_datas($ret);
|
||||||
@@ -536,11 +535,11 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"collections" => $this->list_databox_collections(
|
"collections" => $this->list_databox_collections(
|
||||||
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -559,12 +558,12 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"status" =>
|
"status" =>
|
||||||
$this->list_databox_status(
|
$this->list_databox_status(
|
||||||
$this->app['phraseanet.appbox']->get_databox($databox_id)->get_statusbits()
|
$this->app['phraseanet.appbox']->get_databox($databox_id)->get_statusbits()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -583,13 +582,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"document_metadatas" =>
|
"document_metadatas" =>
|
||||||
$this->list_databox_metadatas_fields(
|
$this->list_databox_metadatas_fields(
|
||||||
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
||||||
->get_meta_structure()
|
->get_meta_structure()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -608,10 +607,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"termsOfUse" =>
|
"termsOfUse" =>
|
||||||
$this->list_databox_terms($this->app['phraseanet.appbox']->get_databox($databox_id))
|
$this->list_databox_terms($this->app['phraseanet.appbox']->get_databox($databox_id))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -683,16 +682,16 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$reasons = $output = null;
|
$reasons = $output = null;
|
||||||
|
|
||||||
$callback = function($element, $visa, $code) use (&$reasons, &$output) {
|
$callback = function($element, $visa, $code) use (&$reasons, &$output) {
|
||||||
if (!$visa->isValid()) {
|
if (!$visa->isValid()) {
|
||||||
$reasons = array();
|
$reasons = array();
|
||||||
|
|
||||||
foreach ($visa->getResponses() as $response) {
|
foreach ($visa->getResponses() as $response) {
|
||||||
$reasons[] = $response->getMessage();
|
$reasons[] = $response->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$output = $element;
|
$output = $element;
|
||||||
};
|
};
|
||||||
|
|
||||||
switch ($request->get('forceBehavior')) {
|
switch ($request->get('forceBehavior')) {
|
||||||
case '0' :
|
case '0' :
|
||||||
@@ -745,7 +744,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$lazaretRepository = $app['EM']->getRepository('Entities\LazaretFile');
|
$lazaretRepository = $app['EM']->getRepository('Entities\LazaretFile');
|
||||||
|
|
||||||
$lazaretFiles = $lazaretRepository->findPerPage(
|
$lazaretFiles = $lazaretRepository->findPerPage(
|
||||||
$baseIds, $offset_start, $per_page
|
$baseIds, $offset_start, $per_page
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1023,7 +1022,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'search_indexes' => $search_result->indexes(),
|
'search_indexes' => $search_result->indexes(),
|
||||||
'suggestions' => $search_result->suggestions()->toArray(),
|
'suggestions' => $search_result->suggestions()->toArray(),
|
||||||
'results' => array(),
|
'results' => array(),
|
||||||
'query' => $search_result->query(),
|
'query' => $search_result->query(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return array($ret, $search_result);
|
return array($ret, $search_result);
|
||||||
@@ -1081,9 +1080,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
|
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"record_metadatas" => $this->list_record_caption($record->get_caption())
|
"record_metadatas" => $this->list_record_caption($record->get_caption())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -1103,17 +1102,17 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result = new API_V1_result($request, $this);
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
$record = $this->app['phraseanet.appbox']
|
$record = $this->app['phraseanet.appbox']
|
||||||
->get_databox($databox_id)
|
->get_databox($databox_id)
|
||||||
->get_record($record_id);
|
->get_record($record_id);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"status" =>
|
"status" =>
|
||||||
$this->list_record_status(
|
$this->list_record_status(
|
||||||
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
$this->app['phraseanet.appbox']->get_databox($databox_id)
|
||||||
, $record->get_status()
|
, $record->get_status()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -1245,7 +1244,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$result->set_datas(array(
|
$result->set_datas(array(
|
||||||
"status" =>
|
"status" =>
|
||||||
$this->list_record_status($databox, $record->get_status())
|
$this->list_record_status($databox, $record->get_status())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
|
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured'));
|
||||||
@@ -1432,10 +1431,10 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], false);
|
$Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['phraseanet.user'], false);
|
||||||
|
|
||||||
$result->set_datas(
|
$result->set_datas(
|
||||||
array(
|
array(
|
||||||
"basket" => $this->list_basket($Basket),
|
"basket" => $this->list_basket($Basket),
|
||||||
"basket_elements" => $this->list_basket_content($Basket)
|
"basket_elements" => $this->list_basket_content($Basket)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -1937,13 +1936,13 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ret = array_merge(
|
$ret = array_merge(
|
||||||
array(
|
array(
|
||||||
'validation_users' => $users,
|
'validation_users' => $users,
|
||||||
'expires_on' => $expires_on_atom,
|
'expires_on' => $expires_on_atom,
|
||||||
'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['phraseanet.user']),
|
'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['phraseanet.user']),
|
||||||
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['phraseanet.user'], $this->app)->getIsConfirmed(),
|
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['phraseanet.user'], $this->app)->getIsConfirmed(),
|
||||||
'validation_initiator' => $basket->getValidation()->isInitiator($this->app['phraseanet.user']),
|
'validation_initiator' => $basket->getValidation()->isInitiator($this->app['phraseanet.user']),
|
||||||
), $ret
|
), $ret
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2191,4 +2190,5 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user