mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 19:13:26 +00:00
CS fixes
This commit is contained in:
@@ -99,8 +99,8 @@ class Structure
|
|||||||
return true;
|
return true;
|
||||||
} elseif (isset($this->fields[$name])) {
|
} elseif (isset($this->fields[$name])) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
throw new DomainException(sprintf('Unknown field "%s".', $name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new DomainException(sprintf('Unknown field "%s".', $name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,33 +36,21 @@ class SearchEngineOptions
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $record_type;
|
protected $record_type;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
protected $search_type = 0;
|
protected $search_type = 0;
|
||||||
|
/** @var \collection[] */
|
||||||
/** @var array */
|
|
||||||
protected $collections = [];
|
protected $collections = [];
|
||||||
|
/** @var \databox_field[] */
|
||||||
/** @var array */
|
|
||||||
protected $fields = [];
|
protected $fields = [];
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
protected $status = [];
|
protected $status = [];
|
||||||
|
|
||||||
/** @var \DateTime */
|
/** @var \DateTime */
|
||||||
protected $date_min;
|
protected $date_min;
|
||||||
|
|
||||||
/** @var \DateTime */
|
/** @var \DateTime */
|
||||||
protected $date_max;
|
protected $date_max;
|
||||||
|
|
||||||
/** @var array */
|
|
||||||
protected $date_fields = [];
|
protected $date_fields = [];
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $i18n;
|
protected $i18n;
|
||||||
|
/** @var bool */
|
||||||
/** @var boolean */
|
|
||||||
protected $stemming = true;
|
protected $stemming = true;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $sort_by;
|
protected $sort_by;
|
||||||
|
|
||||||
@@ -100,7 +88,7 @@ class SearchEngineOptions
|
|||||||
/**
|
/**
|
||||||
* @param string $sort_by
|
* @param string $sort_by
|
||||||
* @param string $sort_ord
|
* @param string $sort_ord
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setSort($sort_by, $sort_ord = self::SORT_MODE_DESC)
|
public function setSort($sort_by, $sort_ord = self::SORT_MODE_DESC)
|
||||||
{
|
{
|
||||||
@@ -113,10 +101,10 @@ class SearchEngineOptions
|
|||||||
/**
|
/**
|
||||||
* Allows business fields query on the given collections
|
* Allows business fields query on the given collections
|
||||||
*
|
*
|
||||||
* @param array $collection An array of collection
|
* @param \collection[] $collection An array of collection
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function allowBusinessFieldsOn(Array $collection)
|
public function allowBusinessFieldsOn(array $collection)
|
||||||
{
|
{
|
||||||
$this->business_fields = $collection;
|
$this->business_fields = $collection;
|
||||||
|
|
||||||
@@ -126,7 +114,7 @@ class SearchEngineOptions
|
|||||||
/**
|
/**
|
||||||
* Reset business fields settings
|
* Reset business fields settings
|
||||||
*
|
*
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function disallowBusinessFields()
|
public function disallowBusinessFields()
|
||||||
{
|
{
|
||||||
@@ -139,7 +127,7 @@ class SearchEngineOptions
|
|||||||
* Returns an array of collection on which business fields are allowed to
|
* Returns an array of collection on which business fields are allowed to
|
||||||
* search on
|
* search on
|
||||||
*
|
*
|
||||||
* @return array An array of collection
|
* @return \collection[] An array of collection
|
||||||
*/
|
*/
|
||||||
public function getBusinessFieldsOn()
|
public function getBusinessFieldsOn()
|
||||||
{
|
{
|
||||||
@@ -170,7 +158,7 @@ class SearchEngineOptions
|
|||||||
* Tells whether to use stemming or not
|
* Tells whether to use stemming or not
|
||||||
*
|
*
|
||||||
* @param boolean $boolean
|
* @param boolean $boolean
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setStemming($boolean)
|
public function setStemming($boolean)
|
||||||
{
|
{
|
||||||
@@ -193,7 +181,7 @@ class SearchEngineOptions
|
|||||||
* Set document type to search for
|
* Set document type to search for
|
||||||
*
|
*
|
||||||
* @param int $search_type
|
* @param int $search_type
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setSearchType($search_type)
|
public function setSearchType($search_type)
|
||||||
{
|
{
|
||||||
@@ -223,10 +211,10 @@ class SearchEngineOptions
|
|||||||
/**
|
/**
|
||||||
* Set the collections where to search for
|
* Set the collections where to search for
|
||||||
*
|
*
|
||||||
* @param array $collections An array of collection
|
* @param \collection[] $collections An array of collection
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function onCollections(Array $collections)
|
public function onCollections(array $collections)
|
||||||
{
|
{
|
||||||
$this->collections = $collections;
|
$this->collections = $collections;
|
||||||
|
|
||||||
@@ -236,7 +224,7 @@ class SearchEngineOptions
|
|||||||
/**
|
/**
|
||||||
* Returns the collections on which the search occurs
|
* Returns the collections on which the search occurs
|
||||||
*
|
*
|
||||||
* @return array An array of collection
|
* @return \collection[] An array of collection
|
||||||
*/
|
*/
|
||||||
public function getCollections()
|
public function getCollections()
|
||||||
{
|
{
|
||||||
@@ -251,35 +239,37 @@ class SearchEngineOptions
|
|||||||
*/
|
*/
|
||||||
public function getDataboxes()
|
public function getDataboxes()
|
||||||
{
|
{
|
||||||
$databoxes = [];
|
if (null === $this->databoxes) {
|
||||||
|
$databoxes = [];
|
||||||
|
foreach ($this->collections as $collection) {
|
||||||
|
$databoxes[$collection->get_databox()->get_sbas_id()] = $collection->get_databox();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->collections as $collection) {
|
$this->databoxes = array_values($databoxes);
|
||||||
$databoxes[$collection->get_databox()->get_sbas_id()] = $collection->get_databox();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($databoxes);
|
return $this->databoxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $fields An array of Databox fields
|
* @param \databox_field[] $fields An array of Databox fields
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setFields(Array $fields)
|
public function setFields(array $fields)
|
||||||
{
|
{
|
||||||
$this->fields = $fields;
|
$this->fields = $fields;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array */
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return $this->fields;
|
return $this->fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $status
|
* @param array $status
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setStatus(array $status)
|
public function setStatus(array $status)
|
||||||
{
|
{
|
||||||
@@ -297,8 +287,8 @@ class SearchEngineOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $record_type
|
* @param string $record_type
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setRecordType($record_type)
|
public function setRecordType($record_type)
|
||||||
{
|
{
|
||||||
@@ -337,7 +327,7 @@ class SearchEngineOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setMinDate(\DateTime $min_date = null)
|
public function setMinDate(\DateTime $min_date = null)
|
||||||
{
|
{
|
||||||
@@ -359,7 +349,7 @@ class SearchEngineOptions
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \DateTime|string $max_date
|
* @param \DateTime|string $max_date
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setMaxDate(\DateTime $max_date = null)
|
public function setMaxDate(\DateTime $max_date = null)
|
||||||
{
|
{
|
||||||
@@ -379,17 +369,17 @@ class SearchEngineOptions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $fields
|
* @param \databox_field[] $fields
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setDateFields(Array $fields)
|
public function setDateFields(array $fields)
|
||||||
{
|
{
|
||||||
$this->date_fields = $fields;
|
$this->date_fields = $fields;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array */
|
/** @return \databox_field[] */
|
||||||
public function getDateFields()
|
public function getDateFields()
|
||||||
{
|
{
|
||||||
return $this->date_fields;
|
return $this->date_fields;
|
||||||
@@ -409,8 +399,8 @@ class SearchEngineOptions
|
|||||||
}
|
}
|
||||||
if (in_array($key, ['collections', 'business_fields'])) {
|
if (in_array($key, ['collections', 'business_fields'])) {
|
||||||
$value = array_map(function (\collection $collection) {
|
$value = array_map(function (\collection $collection) {
|
||||||
return $collection->get_base_id();
|
return $collection->get_base_id();
|
||||||
}, $value);
|
}, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret[$key] = $value;
|
$ret[$key] = $value;
|
||||||
@@ -424,7 +414,7 @@ class SearchEngineOptions
|
|||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param string $serialized
|
* @param string $serialized
|
||||||
*
|
*
|
||||||
* @return SearchEngineOptions
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
@@ -540,7 +530,7 @@ class SearchEngineOptions
|
|||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return SearchEngineOptions
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function fromRequest(Application $app, Request $request)
|
public static function fromRequest(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
|
@@ -11,22 +11,18 @@
|
|||||||
|
|
||||||
class databox_descriptionStructure implements IteratorAggregate, Countable
|
class databox_descriptionStructure implements IteratorAggregate, Countable
|
||||||
{
|
{
|
||||||
/**
|
/** @var databox_field[] */
|
||||||
*
|
|
||||||
* @var Array
|
|
||||||
*/
|
|
||||||
protected $elements = [];
|
protected $elements = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache array for the get element by name function
|
* Cache array for the get element by name function
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var databox_field[]
|
||||||
*/
|
*/
|
||||||
protected $cache_name_id = [];
|
protected $cache_name_id = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return Iterator
|
||||||
* @return databox_field
|
|
||||||
*/
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
@@ -34,9 +30,8 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param databox_field $field
|
||||||
* @param databox_field $field
|
* @return $this
|
||||||
* @return databox_descriptionStructure
|
|
||||||
*/
|
*/
|
||||||
public function add_element(databox_field $field)
|
public function add_element(databox_field $field)
|
||||||
{
|
{
|
||||||
@@ -46,9 +41,8 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param databox_field $field
|
||||||
* @param databox_field $field
|
* @return $this
|
||||||
* @return databox_descriptionStructure
|
|
||||||
*/
|
*/
|
||||||
public function remove_element(databox_field $field)
|
public function remove_element(databox_field $field)
|
||||||
{
|
{
|
||||||
@@ -59,7 +53,6 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return databox_field[]
|
* @return databox_field[]
|
||||||
*/
|
*/
|
||||||
public function get_elements()
|
public function get_elements()
|
||||||
@@ -81,8 +74,7 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param string $name
|
||||||
* @param string $name
|
|
||||||
* @return databox_field
|
* @return databox_field
|
||||||
*/
|
*/
|
||||||
public function get_element_by_name($name)
|
public function get_element_by_name($name)
|
||||||
@@ -118,7 +110,6 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@@ -129,7 +120,7 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
return array_map(function ($element) {
|
return array_map(function (databox_field $element) {
|
||||||
return $element->toArray();
|
return $element->toArray();
|
||||||
}, array_values($this->elements));
|
}, array_values($this->elements));
|
||||||
}
|
}
|
||||||
|
@@ -1655,8 +1655,8 @@ class unicode
|
|||||||
* Removes all digits a the begining of a string
|
* Removes all digits a the begining of a string
|
||||||
* @Example : returns 'soleil' for '123soleil' and 'bb2' for '1bb2'
|
* @Example : returns 'soleil' for '123soleil' and 'bb2' for '1bb2'
|
||||||
*
|
*
|
||||||
* @param type $string
|
* @param string $string
|
||||||
* @return type
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function remove_first_digits($string)
|
public function remove_first_digits($string)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user