Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-09-04 16:13:22 +0300
committerMaxence Lange <maxence@artificial-owl.com>2018-09-04 16:13:22 +0300
commitcacf13615f4fed8d6e94f05c70361128b62e8de9 (patch)
tree494f73884d59fcaafb9b614c42fe63f21c17f909 /lib
parent4541a4a464fadb23a12e4f594e3732f80dfcb6a0 (diff)
removing 'mixed' stuff
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Command/Index.php2
-rw-r--r--lib/Model/Index.php30
-rw-r--r--lib/Model/IndexDocument.php78
-rw-r--r--lib/Model/IndexOptions.php55
-rw-r--r--lib/Model/SearchRequest.php57
5 files changed, 173 insertions, 49 deletions
diff --git a/lib/Command/Index.php b/lib/Command/Index.php
index ca1953b..fbad0bd 100644
--- a/lib/Command/Index.php
+++ b/lib/Command/Index.php
@@ -214,7 +214,7 @@ class Index extends ExtendedBase {
$this->runner->onKeyPress([$this, 'onKeyPressed']);
$this->runner->onNewIndexError([$this, 'onNewIndexError']);
$this->runner->onNewIndexResult([$this, 'onNewIndexResult']);
- $this->runner->pause($options->getOption('paused', false));
+ $this->runner->pause($options->getOptionBool('paused', false));
$this->indexService->setRunner($this->runner);
$this->cliService->setRunner($this->runner);
diff --git a/lib/Model/Index.php b/lib/Model/Index.php
index a854208..ebb69da 100644
--- a/lib/Model/Index.php
+++ b/lib/Model/Index.php
@@ -199,6 +199,19 @@ class Index implements \JsonSerializable {
}
/**
+ * @param string $option
+ * @param int $value
+ *
+ * @return $this
+ */
+ public function addOptionInt($option, $value) {
+ $this->options[$option] = $value;
+
+ return $this;
+ }
+
+
+ /**
* @param array $options
*
* @return $this
@@ -221,7 +234,7 @@ class Index implements \JsonSerializable {
* @param string $option
* @param string $default
*
- * @return mixed|string
+ * @return string
*/
public function getOption($option, $default = '') {
if (!array_key_exists($option, $this->options)) {
@@ -232,6 +245,21 @@ class Index implements \JsonSerializable {
}
+
+ /**
+ * @param string $option
+ * @param int $default
+ *
+ * @return int
+ */
+ public function getOptionInt($option, $default = 0) {
+ if (!array_key_exists($option, $this->options)) {
+ return $default;
+ }
+
+ return $this->options[$option];
+ }
+
/**
* @param int $err
*
diff --git a/lib/Model/IndexDocument.php b/lib/Model/IndexDocument.php
index 50e33d7..12a011c 100644
--- a/lib/Model/IndexDocument.php
+++ b/lib/Model/IndexDocument.php
@@ -32,61 +32,61 @@ class IndexDocument implements \JsonSerializable {
const ENCODED_BASE64 = 1;
/** @var string|int */
- public $id;
+ protected $id;
/** @var string */
- public $providerId;
+ protected $providerId;
/** @var DocumentAccess */
- public $access;
+ protected $access;
/** @var Index */
- public $index;
+ protected $index;
/** @var int */
- public $modifiedTime = 0;
+ protected $modifiedTime = 0;
/** @var string */
- public $source = '';
+ protected $source = '';
/** @var array */
- public $tags = [];
+ protected $tags = [];
/** @var array */
- public $metaTags = [];
+ protected $metaTags = [];
/** @var array */
- public $subTags = [];
+ protected $subTags = [];
/** @var string */
- public $title = '';
+ protected $title = '';
/** @var string */
- public $content = null;
+ protected $content = null;
/** @var string */
- public $hash = '';
+ protected $hash = '';
/** @var array */
- public $parts = [];
+ protected $parts = [];
/** @var string */
- public $link = '';
+ protected $link = '';
/** @var array */
- public $more = [];
+ protected $more = [];
/** @var array */
- public $excerpts = [];
+ protected $excerpts = [];
/** @var string */
- public $score;
+ protected $score;
/** @var array */
- public $info = [];
+ protected $info = [];
/** @var int */
- public $contentEncoded;
+ protected $contentEncoded;
public function __construct($providerId, $id) {
@@ -95,16 +95,16 @@ class IndexDocument implements \JsonSerializable {
}
- /**
- * @param string|integer $id
- *
- * @return $this
- */
- public function setId($id) {
- $this->id = $id;
-
- return $this;
- }
+// /**
+// * @param string|integer $id
+// *
+// * @return $this
+// */
+// public function setId($id) {
+// $this->id = $id;
+//
+// return $this;
+// }
/**
* @return string|integer
@@ -114,16 +114,16 @@ class IndexDocument implements \JsonSerializable {
}
- /**
- * @param string $providerId
- *
- * @return $this
- */
- public function setProviderId($providerId) {
- $this->providerId = $providerId;
-
- return $this;
- }
+// /**
+// * @param string $providerId
+// *
+// * @return $this
+// */
+// public function setProviderId($providerId) {
+// $this->providerId = $providerId;
+//
+// return $this;
+// }
/**
* @return string
diff --git a/lib/Model/IndexOptions.php b/lib/Model/IndexOptions.php
index 9b5b269..2c5456e 100644
--- a/lib/Model/IndexOptions.php
+++ b/lib/Model/IndexOptions.php
@@ -61,12 +61,28 @@ class IndexOptions implements \JsonSerializable {
$this->options[$k] = $v;
}
+ /**
+ * @param string $k
+ * @param array $array
+ */
+ public function addOptionArray($k, $array) {
+ $this->options[$k] = $array;
+ }
+
+ /**
+ * @param string $k
+ * @param bool $bool
+ */
+ public function addOptionBool($k, $bool) {
+ $this->options[$k] = $bool;
+ }
+
/**
* @param string $k
* @param string $default
*
- * @return array|string
+ * @return string
*/
public function getOption($k, $default = '') {
if (array_key_exists($k, $this->options)) {
@@ -76,6 +92,43 @@ class IndexOptions implements \JsonSerializable {
return $default;
}
+
+ /**
+ * @param string $option
+ * @param array $default
+ *
+ * @return array
+ */
+ public function getOptionArray($option, $default = []) {
+ if (array_key_exists($option, $this->options)) {
+ $options = $this->options[$option];
+ if (is_array($options)) {
+ return $this->options[$option];
+ }
+ }
+
+ return $default;
+ }
+
+
+ /**
+ * @param string $option
+ * @param bool $default
+ *
+ * @return bool
+ */
+ public function getOptionBool($option, $default) {
+ if (array_key_exists($option, $this->options)) {
+ $options = $this->options[$option];
+ if (is_bool($options)) {
+ return $this->options[$option];
+ }
+ }
+
+ return $default;
+ }
+
+
/**
* Specify data which should be serialized to JSON
*
diff --git a/lib/Model/SearchRequest.php b/lib/Model/SearchRequest.php
index a349ec2..0fce57a 100644
--- a/lib/Model/SearchRequest.php
+++ b/lib/Model/SearchRequest.php
@@ -94,13 +94,9 @@ class SearchRequest implements \JsonSerializable {
}
/**
- * @param string|array $providers
+ * @param array $providers
*/
public function setProviders($providers) {
- if (!is_array($providers)) {
- $providers = [$providers];
- }
-
$this->providers = $providers;
}
@@ -246,6 +242,30 @@ class SearchRequest implements \JsonSerializable {
}
/**
+ * @param string $k
+ * @param array $array
+ *
+ * @return SearchRequest
+ */
+ public function addOptionArray($k, $array) {
+ $this->options[$k] = $array;
+
+ return $this;
+ }
+
+ /**
+ * @param string $k
+ * @param bool $bool
+ *
+ * @return SearchRequest
+ */
+ public function addOptionBool($k, $bool) {
+ $this->options[$k] = $bool;
+
+ return $this;
+ }
+
+ /**
* @param $key
* @param $value
*
@@ -265,7 +285,7 @@ class SearchRequest implements \JsonSerializable {
* @param string $option
* @param string $default
*
- * @return mixed|string
+ * @return string
*/
public function getOption($option, $default = '') {
if (array_key_exists($option, $this->options)) {
@@ -277,6 +297,24 @@ class SearchRequest implements \JsonSerializable {
/**
+ * @param string $option
+ * @param array $default
+ *
+ * @return array
+ */
+ public function getOptionArray($option, $default = []) {
+ if (array_key_exists($option, $this->options)) {
+ $options = $this->options[$option];
+ if (is_array($options)) {
+ return $this->options[$option];
+ }
+ }
+
+ return $default;
+ }
+
+
+ /**
* @param array $parts
*
* @return $this
@@ -591,8 +629,13 @@ class SearchRequest implements \JsonSerializable {
* @return SearchRequest
*/
public static function fromArray($arr) {
+ $providers = $arr['providers'];
+ if (!is_array($providers)) {
+ $providers = [$providers];
+ }
+
$request = new SearchRequest();
- $request->setProviders($arr['providers']);
+ $request->setProviders($providers);
$request->setAuthor(MiscService::get('author', $arr, ''));
$request->setSearch(MiscService::get('search', $arr, ''));
$request->setPage(MiscService::get('page', $arr, 0));