mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Context changes to support basic text searching
This commit is contained in:
parent
ad8057a40b
commit
f9fde23708
1 changed files with 23 additions and 3 deletions
|
@ -34,6 +34,7 @@ class Context {
|
|||
public $labelName;
|
||||
public $labelled = null;
|
||||
public $annotated = null;
|
||||
public $searchTerms = [];
|
||||
|
||||
protected $props = [];
|
||||
|
||||
|
@ -52,7 +53,7 @@ class Context {
|
|||
}
|
||||
}
|
||||
|
||||
protected function cleanArray(array $spec): array {
|
||||
protected function cleanIdArray(array $spec): array {
|
||||
$spec = array_values($spec);
|
||||
for ($a = 0; $a < sizeof($spec); $a++) {
|
||||
if (ValueInfo::id($spec[$a])) {
|
||||
|
@ -64,6 +65,18 @@ class Context {
|
|||
return array_values(array_filter($spec));
|
||||
}
|
||||
|
||||
protected function cleanStringArray(array $spec): array {
|
||||
$spec = array_values($spec);
|
||||
for ($a = 0; $a < sizeof($spec); $a++) {
|
||||
if (strlen($str = ValueInfo::normalize($spec[$a], ValueInfo::T_STRING))) {
|
||||
$spec[$a] = $str;
|
||||
} else {
|
||||
unset($spec[$a]);
|
||||
}
|
||||
}
|
||||
return array_values($spec);
|
||||
}
|
||||
|
||||
public function reverse(bool $spec = null) {
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
||||
|
@ -142,14 +155,14 @@ class Context {
|
|||
|
||||
public function editions(array $spec = null) {
|
||||
if (isset($spec)) {
|
||||
$spec = $this->cleanArray($spec);
|
||||
$spec = $this->cleanIdArray($spec);
|
||||
}
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
||||
|
||||
public function articles(array $spec = null) {
|
||||
if (isset($spec)) {
|
||||
$spec = $this->cleanArray($spec);
|
||||
$spec = $this->cleanIdArray($spec);
|
||||
}
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
||||
|
@ -169,4 +182,11 @@ class Context {
|
|||
public function annotated(bool $spec = null) {
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
||||
|
||||
public function searchTerms(array $spec = null) {
|
||||
if (isset($spec)) {
|
||||
$spec = $this->cleanStringArray($spec);
|
||||
}
|
||||
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue