Manage threaded topics / comment topics.

package core_feedback_features

 Methods

Constructor.

__construct() 

Get a form for posting.

get_posting_form(\ID_TEXT $type, \ID_TEXT $id, boolean $allow_reviews, \Tempcode $post_url, \?string $post_warning) : \Tempcode

Parameters

$type

\ID_TEXT

The content type of what this posting will be for

$id

\ID_TEXT

The content ID of what this posting will be for

$allow_reviews

boolean

Whether to accept reviews

$post_url

\Tempcode

URL where form submit will go

$post_warning

\?string

The default post to use (null: standard courtesy warning)

Returns

\TempcodePosting form

Put in posts to our scoring algorithm in preparation for shooting out later.

inject_posts_for_scoring_algorithm(array $posts) 

Parameters

$posts

array

Review titles

Put comments RSS link into environment.

inject_rss_url(\ID_TEXT $forum, \ID_TEXT $type, \ID_TEXT $id) 

Parameters

$forum

\ID_TEXT

The forum we are working in

$type

\ID_TEXT

The content type the comments are for

$id

\ID_TEXT

The content ID the comments are for

Load from a given topic ID.

load_from_topic(\?AUTO_LINK $topic_id, integer $num_to_show_limit, integer $start = 0, \?boolean $reverse = null, \?array $posts = null, boolean $load_spacer_posts_too = false) : boolean

Parameters

$topic_id

\?AUTO_LINK

Topic ID (null: none yet, set up empty structure)

$num_to_show_limit

integer

Maximum to load

$start

integer

Pagination start if non-threaded

$reverse

\?boolean

Whether to show in reverse date order (affects default search order only) (null: read config)

$posts

\?array

List of post IDs to load (null: no filter)

$load_spacer_posts_too

boolean

Whether to allow spacer posts to flow through the renderer

Returns

booleanSuccess status

Render a comment topic.

render_as_comment_topic(\ID_TEXT $content_type, \ID_TEXT $content_id, boolean $allow_comments, boolean $invisible_if_no_comments, \?string $forum_name, \?string $post_warning, \?mixed $preloaded_comments, boolean $explicit_allow, boolean $reverse, \?MEMBER $highlight_by_member, boolean $allow_reviews, \?integer $num_to_show_limit) : \Tempcode

Parameters

$content_type

\ID_TEXT

Content type to show topic for

$content_id

\ID_TEXT

Content ID of content type to show topic for

$allow_comments

boolean

Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function)

$invisible_if_no_comments

boolean

Whether the comment box will be invisible if there are not yet any comments (and you're not staff)

$forum_name

\?string

The name of the forum to use (null: default comment forum)

$post_warning

\?string

The default post to use (null: standard courtesy warning)

$preloaded_comments

\?mixed

The raw comment array (null: lookup). This is useful if we want to pass it through a filter

$explicit_allow

boolean

Whether to skip permission checks

$reverse

boolean

Whether to reverse the posts

$highlight_by_member

\?MEMBER

Member to highlight the posts of (null: none)

$allow_reviews

boolean

Whether to allow ratings along with the comment (like reviews)

$num_to_show_limit

\?integer

Maximum to load (null: default)

Returns

\TempcodeThe Tempcode for the comment topic

Render a topic.

render_posts(\?integer $num_to_show_limit, integer $max_thread_depth, boolean $may_reply, \?MEMBER $highlight_by_member, array $all_individual_review_ratings, \AUTO_LINK $forum_id, \?array $topic_info, \?AUTO_LINK $parent_post_id = null, boolean $maybe_missing_links = false) : array

Parameters

$num_to_show_limit

\?integer

Number of posts to show initially (null: no limit)

$max_thread_depth

integer

Maximum thread depth

$may_reply

boolean

Whether the current user may reply to the topic (influences what buttons show)

$highlight_by_member

\?MEMBER

Member to highlight the posts of (null: none)

$all_individual_review_ratings

array

Review ratings rows

$forum_id

\AUTO_LINK

ID of forum this topic in in

$topic_info

\?array

The topic row (null: not running Conversr).

$parent_post_id

\?AUTO_LINK

Only show posts under here (null: show posts from root)

$maybe_missing_links

boolean

Whether to just render everything as flat (used when doing AJAX post loading). NOT actually used since we wrote better post-orphaning-fixing code.

Returns

arrayTuple: Rendered topic, serialized options to render more posts, secure hash of serialized options to prevent tampering

Render posts from a topic (usually tied into AJAX, to get iterative results).

render_posts_from_topic(\AUTO_LINK $topic_id, integer $num_to_show_limit, boolean $allow_comments, boolean $invisible_if_no_comments, \?string $forum_name, \?mixed $preloaded_comments, boolean $reverse, boolean $may_reply, \?MEMBER $highlight_by_member, boolean $allow_reviews, array $posts, \AUTO_LINK $parent_id) : \Tempcode

Parameters

$topic_id

\AUTO_LINK

The topic ID

$num_to_show_limit

integer

Maximum to load

$allow_comments

boolean

Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function)

$invisible_if_no_comments

boolean

Whether the comment box will be invisible if there are not yet any comments (and you're not staff)

$forum_name

\?string

The name of the forum to use (null: default comment forum)

$preloaded_comments

\?mixed

The raw comment array (null: lookup). This is useful if we want to pass it through a filter

$reverse

boolean

Whether to reverse the posts

$may_reply

boolean

Whether the current user may reply to the topic (influences what buttons show)

$highlight_by_member

\?MEMBER

Member to highlight the posts of (null: none)

$allow_reviews

boolean

Whether to allow ratings along with the comment (like reviews)

$posts

array

List of post IDs to load

$parent_id

\AUTO_LINK

Parent node being loaded to

Returns

\TempcodeThe Tempcode for the comment topic

Set a rendering context.

set_rendering_context(\ID_TEXT $rendering_context) 

Parameters

$rendering_context

\ID_TEXT

Rendering context

Set the particular review criteria we'll be dealing with.

set_reviews_rating_criteria(array $reviews_rating_criteria) 

Parameters

$reviews_rating_criteria

array

Review criteria

Arrange posts underneath a post in the thread (not including the post itself).

_arrange_posts_in_tree(\?AUTO_LINK $post_id, array $posts, array $queue, integer $max_thread_depth, integer $depth = 0) : array

Parameters

$post_id

\?AUTO_LINK

Reference post in thread (null: root)

$posts

array

Posts we will be rendering and have not arranged yet (only some of which will be underneath $post_id)

$queue

array

Posts we won't be rendering

$max_thread_depth

integer

Maximum depth to render to

$depth

integer

Current depth in recursion

Returns

arrayArray structure of rendered posts

Filter posts, deciding what to render.

_decide_what_to_render(integer $num_to_show_limit, array $queue) : array

Parameters

$num_to_show_limit

integer

Number of posts to show initially

$queue

array

Posts to choose from, in preference order

Returns

arrayChosen posts

Get the sort order.

_get_sort_order(\?boolean $reverse) : \ID_TEXT
set relevance rating newest oldest

Parameters

$reverse

\?boolean

Whether to show in reverse date order (affects default search order only) (null: read config)

Returns

\ID_TEXTSort order

Grab posts at or above a reference post and remove from queue.

_grab_at_and_above_and_remove(\AUTO_LINK $post_id, array $queue, array $posts) 

Parameters

$post_id

\AUTO_LINK

Reference post in thread

$queue

array

Posts to choose from (the queue)

$posts

array

Posts picked out (passed by reference)

Grab posts at or underneath a reference post.

_grab_at_and_underneath(\?AUTO_LINK $parent_post_id, array $posts_in) : array

Parameters

$parent_post_id

\?AUTO_LINK

Reference post in thread (null: root)

$posts_in

array

Posts to choose from

Returns

arrayRelevant posts

Load full details for posts (we had not done so far to preserve memory).

_grab_full_post_details(array $posts) : array

Parameters

$posts

array

Posts to load

Returns

arrayUpgraded posts

Render posts.

_render_post_tree(integer $num_to_show_limit, array $tree, boolean $may_reply, \?AUTO_LINK $highlight_by_member, array $all_individual_review_ratings, \AUTO_LINK $forum_id, \?array $topic_info, integer $depth = 0) : \Tempcode

Parameters

$num_to_show_limit

integer

Maximum to load

$tree

array

Tree structure of posts

$may_reply

boolean

Whether the current user may reply to the topic (influences what buttons show)

$highlight_by_member

\?AUTO_LINK

Only show posts under here (null: show posts from root)

$all_individual_review_ratings

array

Review ratings rows

$forum_id

\AUTO_LINK

ID of forum this topic in in

$topic_info

\?array

The topic row (null: not running Conversr).

$depth

integer

The recursion depth

Returns

\TempcodeRendered tree structure

 Properties

 

$all_posts_ordered

$all_posts_ordered 

Default

null
 

$error

$error 

Default

false
 

$first_post_id

$first_post_id 

Default

null
 

$is_threaded

$is_threaded 

Default

null
 

$rendering_context

$rendering_context 

Default

'cns'
 

$replied

$replied 

Default

false
 

$reverse

$reverse 

Default

false
 

$reviews_rating_criteria

$reviews_rating_criteria 

Default

array()
 

$topic_description

$topic_description 

Default

null
   

$topic_id

$topic_id 

Default

null
 

$topic_info

$topic_info 

Default

null
 

$topic_title

$topic_title 

Default

null
 

$total_posts

$total_posts 

Default

null