2022-04-19 02:04:48 +00:00
|
|
|
<?php
|
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-03-23 03:33:05 +00:00
|
|
|
|
2022-04-19 02:04:48 +00:00
|
|
|
namespace JKingWeb\Arsse\Context;
|
|
|
|
|
|
|
|
use JKingWeb\Arsse\Misc\ValueInfo;
|
|
|
|
use JKingWeb\Arsse\Misc\Date;
|
|
|
|
|
2022-04-20 03:20:20 +00:00
|
|
|
trait ExclusionMembers {
|
|
|
|
public $folder = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $folders = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $folderShallow = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $foldersShallow = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $tag = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $tags = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $tagName = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $tagNames = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $subscription = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $subscriptions = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $edition = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $editions = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $article = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $articles = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $label = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $labels = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $labelName = null;
|
2022-04-22 23:22:50 +00:00
|
|
|
public $labelNames = [];
|
|
|
|
public $annotationTerms = [];
|
|
|
|
public $searchTerms = [];
|
|
|
|
public $titleTerms = [];
|
|
|
|
public $authorTerms = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $articleRange = [null, null];
|
|
|
|
public $editionRange = [null, null];
|
|
|
|
public $modifiedRange = [null, null];
|
2022-04-23 00:09:07 +00:00
|
|
|
public $modifiedRanges = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
public $markedRange = [null, null];
|
2022-04-23 00:09:07 +00:00
|
|
|
public $markedRanges = [];
|
2022-04-20 03:20:20 +00:00
|
|
|
|
2022-04-19 02:04:48 +00:00
|
|
|
protected function cleanIdArray(array $spec, bool $allowZero = false): array {
|
|
|
|
$spec = array_values($spec);
|
|
|
|
for ($a = 0; $a < sizeof($spec); $a++) {
|
|
|
|
if (ValueInfo::id($spec[$a], $allowZero)) {
|
|
|
|
$spec[$a] = (int) $spec[$a];
|
|
|
|
} else {
|
|
|
|
$spec[$a] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return array_values(array_unique(array_filter($spec, function($v) {
|
|
|
|
return !is_null($v);
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function cleanStringArray(array $spec): array {
|
|
|
|
$spec = array_values($spec);
|
|
|
|
$stop = sizeof($spec);
|
|
|
|
for ($a = 0; $a < $stop; $a++) {
|
|
|
|
if (strlen($str = ValueInfo::normalize($spec[$a], ValueInfo::T_STRING | ValueInfo::M_DROP) ?? "")) {
|
|
|
|
$spec[$a] = $str;
|
|
|
|
} else {
|
|
|
|
unset($spec[$a]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return array_values(array_unique($spec));
|
|
|
|
}
|
|
|
|
|
2022-04-23 00:09:07 +00:00
|
|
|
protected function cleanDateRangeArray(array $spec): array {
|
|
|
|
$spec = array_values($spec);
|
|
|
|
$stop = sizeof($spec);
|
|
|
|
for ($a = 0; $a < $stop; $a++) {
|
|
|
|
if (!is_array($spec[$a]) || sizeof($spec[$a]) !== 2) {
|
|
|
|
unset($spec[$a]);
|
|
|
|
} else {
|
|
|
|
$spec[$a] = ValueInfo::normalize($spec[$a], ValueInfo::T_DATE | ValueInfo::M_ARRAY | ValueInfo::M_DROP);
|
|
|
|
if ($spec[$a] === [null, null]) {
|
|
|
|
unset($spec[$a]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-24 16:25:37 +00:00
|
|
|
return array_values(array_unique($spec, \SORT_REGULAR));
|
2022-04-23 00:09:07 +00:00
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function folder(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function folders(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec, true);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function folderShallow(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function foldersShallow(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec, true);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function tag(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function tags(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function tagName(?string $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function tagNames(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function subscription(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function subscriptions(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function edition(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function article(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function editions(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function articles(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function label(?int $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function labels(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanIdArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function labelName(?string $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function labelNames(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function annotationTerms(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function searchTerms(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function titleTerms(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function authorTerms(?array $spec = null) {
|
2022-04-19 02:04:48 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanStringArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2022-04-20 00:19:51 +00:00
|
|
|
public function articleRange(?int $start = null, ?int $end = null) {
|
|
|
|
if ($start === null && $end === null) {
|
|
|
|
$spec = null;
|
|
|
|
} else {
|
|
|
|
$spec = [$start, $end];
|
|
|
|
}
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2022-04-20 00:19:51 +00:00
|
|
|
public function editionRange(?int $start = null, ?int $end = null) {
|
|
|
|
if ($start === null && $end === null) {
|
|
|
|
$spec = null;
|
|
|
|
} else {
|
|
|
|
$spec = [$start, $end];
|
|
|
|
}
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2022-04-20 00:19:51 +00:00
|
|
|
public function modifiedRange($start = null, $end = null) {
|
|
|
|
if ($start === null && $end === null) {
|
|
|
|
$spec = null;
|
|
|
|
} else {
|
|
|
|
$spec = [Date::normalize($start), Date::normalize($end)];
|
|
|
|
}
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function modifiedRanges(?array $spec = null) {
|
2022-04-23 00:09:07 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanDateRangeArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
|
|
|
|
2022-04-20 00:19:51 +00:00
|
|
|
public function markedRange($start = null, $end = null) {
|
|
|
|
if ($start === null && $end === null) {
|
|
|
|
$spec = null;
|
|
|
|
} else {
|
|
|
|
$spec = [Date::normalize($start), Date::normalize($end)];
|
|
|
|
}
|
2022-04-19 02:04:48 +00:00
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
2022-04-23 00:09:07 +00:00
|
|
|
|
2024-12-15 21:31:57 +00:00
|
|
|
public function markedRanges(?array $spec = null) {
|
2022-04-23 00:09:07 +00:00
|
|
|
if (isset($spec)) {
|
|
|
|
$spec = $this->cleanDateRangeArray($spec);
|
|
|
|
}
|
|
|
|
return $this->act(__FUNCTION__, func_num_args(), $spec);
|
|
|
|
}
|
2022-04-19 02:04:48 +00:00
|
|
|
}
|