CoolCMS API

HandleTrait

One-click star rating (`STYLE_CLASSIC`).

Requires in the host class: $this->ratingManager, $this->threadId, $this->translatorDomain, canVote().

Table of Contents

Methods

handleFilterStars()  : void
AJAX signal: filters the list by star count (0 clears the filter).
handlePage()  : void
AJAX signal: switches the review list page.
handleRate()  : void
AJAX signal: saves the star rating (1-5) and redraws the component.
handleReportReview()  : void
AJAX signal: reports an inappropriate review.
handleSortReviews()  : void
AJAX signal: sorts the review list. An unknown value falls back to "newest" (checked by `resolveSort()` on render), so a hand-edited URL breaks nothing.
handleVoteReview()  : void
AJAX signal: vote on the helpfulness of one review (thumb up/down).
buildRating()  : Rating
Builds the rating entity shared by stars and reviews.

Methods

handleFilterStars()

AJAX signal: filters the list by star count (0 clears the filter).

public handleFilterStars(int $stars) : void

Pagination returns to the first page because a narrower selection has fewer pages.

Parameters
$stars : int

handlePage()

AJAX signal: switches the review list page.

public handlePage(int $page) : void
Parameters
$page : int

handleRate()

AJAX signal: saves the star rating (1-5) and redraws the component.

public handleRate(int $value) : void
Parameters
$value : int
Attributes
#[Requires]
$ajax: true

handleReportReview()

AJAX signal: reports an inappropriate review.

public handleReportReview(int $ratingId) : void

It neither deletes nor hides the review, only flags it for moderation; only an admin can delete it. The Api rejects a repeated report by the same person (dedup like votes).

Parameters
$ratingId : int
Attributes
#[Requires]
$ajax: true

handleSortReviews()

AJAX signal: sorts the review list. An unknown value falls back to "newest" (checked by `resolveSort()` on render), so a hand-edited URL breaks nothing.

public handleSortReviews(string $sort) : void
Parameters
$sort : string

handleVoteReview()

AJAX signal: vote on the helpfulness of one review (thumb up/down).

public handleVoteReview(int $ratingId, int $up) : void

The component decides nothing here: it takes identity and IP from the server and passes them to the Api, which decides whether an anonymous visitor may vote (setting 2/rating.allowAnonymousReviewVote) and whether this visitor already voted. A duplicate vote is rejected, not overwritten, hence result.duplicated.

Parameters
$ratingId : int
$up : int
Attributes
#[Requires]
$ajax: true

buildRating()

Builds the rating entity shared by stars and reviews.

private buildRating(int $value) : Rating

Approval is handled by the Api layer in beforeSave per the setting ratingUseAutoApproval.

Parameters
$value : int
Return values
Rating
On this page

Search results