CoolCMS API

MessageListTrait uses trait:short

Table of Contents

Constants

LIST_INCLUDES  : mixed = ['asset', 'categories.translations', 'commentTh...
Includes of the list, the same for the plain DB path and the search endpoint. The post image is `asset`; there is no `image` association.

Properties

$fromEs  : bool
True when order and `totalCount` come from Elasticsearch (relevance).
$searchHighlights  : array<int, array<string, string>>

Methods

actionHomepage()  : void
actionList()  : void
paginationInit()  : Paginator|null
prepareUserForList()  : void
renderList()  : void
requirePagination()  : Paginator
Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.
prepareCanonicalUrl()  : void
prepareFilters()  : array<int, Filter>
prepareMessageSearchFilter()  : Filter
Full-text search through Elasticsearch (ids go to `SearchIdFilter`; visibility, level and pagination stay in the DB phase 1). When Elasticsearch is disabled, down or the query is short, it transparently falls back to MySQL `MATCH_AGAINST` over subject and text.
prepareOgDataForList()  : void
prepareOrderBy()  : array<string, bool>
preparePerPage()  : int
prepareView()  : void
searchViaApi()  : Message>, 1: int, 2: bool, 3: array>}|null
Searches through the Api endpoint `api/discussion/message/search`.

Constants

LIST_INCLUDES

Includes of the list, the same for the plain DB path and the search endpoint. The post image is `asset`; there is no `image` association.

private mixed LIST_INCLUDES = ['asset', 'categories.translations', 'commentThread', 'ratingThread']

Properties

$fromEs

True when order and `totalCount` come from Elasticsearch (relevance).

private bool $fromEs = false

$searchHighlights

private array<int, array<string, string>> $searchHighlights = []

thread id => field => safe HTML

Methods

actionHomepage()

public actionHomepage([int $page = 1 ][, string|null $search = null ]) : void
Parameters
$page : int = 1
$search : string|null = null

actionList()

public actionList([int $page = 1 ][, string|null $search = null ][, int $count = 0 ]) : void
Parameters
$page : int = 1
$search : string|null = null
$count : int = 0

renderList()

public renderList([int $page = 1 ][, string|null $search = null ]) : void
Parameters
$page : int = 1
$search : string|null = null

requirePagination()

Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.

public requirePagination(int $perPage) : Paginator
Parameters
$perPage : int
Return values
Paginator

prepareFilters()

private prepareFilters([string|null $search = null ][, array<string|int, int>|null $messageIds = null ]) : array<int, Filter>
Parameters
$search : string|null = null
$messageIds : array<string|int, int>|null = null
Return values
array<int, Filter>

prepareMessageSearchFilter()

Full-text search through Elasticsearch (ids go to `SearchIdFilter`; visibility, level and pagination stay in the DB phase 1). When Elasticsearch is disabled, down or the query is short, it transparently falls back to MySQL `MATCH_AGAINST` over subject and text.

private prepareMessageSearchFilter(string $search) : Filter

Message has no language: one global index, the language alias is null.

Parameters
$search : string
Return values
Filter

prepareOrderBy()

private prepareOrderBy() : array<string, bool>
Return values
array<string, bool>

preparePerPage()

private preparePerPage(int $count[, int $defaultCount = 20 ]) : int
Parameters
$count : int
$defaultCount : int = 20
Return values
int

searchViaApi()

Searches through the Api endpoint `api/discussion/message/search`.

private searchViaApi(string $search, bool $orderChosen, Paginator|null $paginator) : Message>, 1: int, 2: bool, 3: array>}|null

Three states:

  • (a) search without a manual sort choice: orderBys = null, Elasticsearch sorts and paginates by score (fromEs: true); the DB keeps visibility.
  • (b) search with a manual choice (/o-N): orderBys from prepareOrderBy(), the DB sorts, paginates and counts over the Elasticsearch id set.
  • (c) without a search this path is never reached; nothing changes.

IMPORTANT: deliberate deviation: in state (a) the precedence of topped threads does not apply. prepareOrderBy() normally puts topedUntil > NOW() first, but Elasticsearch composes the relevance page.

null means use the plain DB path (deny, bridge outage or Elasticsearch unavailable).

Parameters
$search : string
$orderChosen : bool
$paginator : Paginator|null
Return values
Message>, 1: int, 2: bool, 3: array>}|null
On this page

Search results