Filter user defined channels by size

This commit is contained in:
Michael 2024-01-30 10:05:05 +00:00
parent 0c583574e1
commit 3fe4991fcf
12 changed files with 68 additions and 5 deletions

View file

@ -427,6 +427,14 @@ class Timeline extends BaseModule
$condition = DBA::mergeConditions($condition, array_merge(["NOT `uri-id` IN (SELECT `uri-id` FROM `post-tag` INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid` WHERE `post-tag`.`type` = 1 AND `name` IN (" . $placeholders . "))"], $search));
}
if (!is_null($channel->minSize)) {
$condition = DBA::mergeConditions($condition, ["`size` >= ?", $channel->minSize]);
}
if (!is_null($channel->maxSize)) {
$condition = DBA::mergeConditions($condition, ["`size` <= ?", $channel->maxSize]);
}
if (!empty($channel->mediaType)) {
$condition = DBA::mergeConditions($condition, ["`media-type` & ?", $channel->mediaType]);
}

View file

@ -83,6 +83,8 @@ class Channels extends BaseSettings
'circle' => (int)$request['new_circle'],
'include-tags' => Strings::cleanTags($request['new_include_tags']),
'exclude-tags' => Strings::cleanTags($request['new_exclude_tags']),
'min-size' => $request['new_min_size'] != '' ? (int)$request['new_min_size'] : null,
'max-size' => $request['new_max_size'] != '' ? (int)$request['new_max_size'] : null,
'full-text-search' => $request['new_text_search'],
'media-type' => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0),
'languages' => $request['new_languages'],
@ -112,6 +114,8 @@ class Channels extends BaseSettings
'circle' => (int)$request['circle'][$id],
'include-tags' => Strings::cleanTags($request['include_tags'][$id]),
'exclude-tags' => Strings::cleanTags($request['exclude_tags'][$id]),
'min-size' => $request['min_size'][$id] != '' ? (int)$request['min_size'][$id] : null,
'max-size' => $request['max_size'][$id] != '' ? (int)$request['max_size'][$id] : null,
'full-text-search' => $request['text_search'][$id],
'media-type' => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0),
'languages' => $request['languages'][$id],
@ -181,6 +185,8 @@ class Channels extends BaseSettings
'circle' => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles],
'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), str_replace(',', ', ', $channel->includeTags)],
'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), str_replace(',', ', ', $channel->excludeTags)],
'min_size' => ["min_size[$channel->code]", $this->t("Minimum Size"), $channel->minSize],
'max_size' => ["max_size[$channel->code]", $this->t("Maximum Size"), $channel->maxSize],
'text_search' => ["text_search[$channel->code]", $this->t("Full Text Search"), $channel->fullTextSearch],
'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1],
'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
@ -200,6 +206,8 @@ class Channels extends BaseSettings
'circle' => ['new_circle', $this->t('Circle/Channel'), 0, $this->t('Select a circle or channel, that your channel should be based on.'), $circles],
'include_tags' => ["new_include_tags", $this->t("Include Tags"), '', $this->t('Comma separated list of tags. A post will be used when it contains any of the listed tags.')],
'exclude_tags' => ["new_exclude_tags", $this->t("Exclude Tags"), '', $this->t('Comma separated list of tags. If a post contain any of these tags, then it will not be part of nthis channel.')],
'min_size' => ["new_min_size", $this->t("Minimum Size"), '', $this->t('Minimum post size. Leave empty for no minimum size. The size is calculated without links, attached posts, mentions or hashtags.')],
'max_size' => ["new_max_size", $this->t("Maximum Size"), '', $this->t('Maximum post size. Leave empty for no maximum size. The size is calculated without links, attached posts, mentions or hashtags.')],
'text_search' => ["new_text_search", $this->t("Full Text Search"), '', $this->t('Search terms for the body, supports the "boolean mode" operators from MariaDB. See the help for a complete list of operators and additional keywords: %s', '<a href="help/Channels">help/Channels</a>')],
'image' => ['new_image', $this->t("Images"), false, $this->t("Check to display images in the channel.")],
'video' => ["new_video", $this->t("Videos"), false, $this->t("Check to display videos in the channel.")],