make_thread_list($threads, $showAdminOptions); } $page->set_title(html_escape("Forum")); $page->set_heading(html_escape("Forum")); $page->add_block(new Block("Forum", $html, "main", 10)); $this->display_paginator($page, "forum/index", null, $pageNumber, $totalPages); } public function display_new_thread_composer(Page $page, $threadText = null, $threadTitle = null) { global $config, $user; $max_characters = $config->get_int('forumMaxCharsPerPost'); $html = make_form(make_link("forum/create")); if (!is_null($threadTitle)) { $threadTitle = html_escape($threadTitle); } if (!is_null($threadText)) { $threadText = html_escape($threadText); } $html .= " "; if ($user->can(Permissions::FORUM_ADMIN)) { $html .= ""; } $html .= "
Title:
Message:
Max characters alowed: $max_characters.
"; $blockTitle = "Write a new thread"; $page->set_title(html_escape($blockTitle)); $page->set_heading(html_escape($blockTitle)); $page->add_block(new Block($blockTitle, $html, "main", 120)); } public function display_new_post_composer(Page $page, $threadID) { global $config; $max_characters = $config->get_int('forumMaxCharsPerPost'); $html = make_form(make_link("forum/answer")); $html .= ''; $html .= " "; $html .= "
Message:
Max characters alowed: $max_characters.
"; $blockTitle = "Answer to this thread"; $page->add_block(new Block($blockTitle, $html, "main", 130)); } public function display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber, $totalPages) { global $config, $page/*, $user*/; $posts_per_page = $config->get_int('forumPostsPerPage'); $current_post = 0; $html = "

". "". "". "". "". ""; foreach ($posts as $post) { $current_post++; $message = $post["message"]; $message = send_event(new TextFormattingEvent($message))->formatted; $message = str_replace('\n\r', '
', $message); $message = str_replace('\r\n', '
', $message); $message = str_replace('\n', '
', $message); $message = str_replace('\r', '
', $message); $message = stripslashes($message); $userLink = "".$post["user_name"].""; $poster = User::by_name($post["user_name"]); $gravatar = $poster->get_avatar_html(); $rank = "{$post["user_class"]}"; $postID = $post['id']; //if($user->can(Permissions::FORUM_ADMIN)){ //$delete_link = "Delete"; //} else { //$delete_link = ""; //} if ($showAdminOptions) { $delete_link = "Delete"; } else { $delete_link = ""; } $post_number = (($pageNumber-1)*$posts_per_page)+$current_post; $html .= ""; } $html .= "
UserMessage
".$userLink."
".$rank."
".$gravatar."
#".$post_number."

".$message."
"; $this->display_paginator($page, "forum/view/".$threadID, null, $pageNumber, $totalPages); $page->set_title(html_escape($threadTitle)); $page->set_heading(html_escape($threadTitle)); $page->add_block(new Block($threadTitle, $html, "main", 20)); } public function add_actions_block(Page $page, $threadID) { $html = 'Delete this thread and its posts.'; $page->add_block(new Block("Admin Actions", $html, "main", 140)); } private function make_thread_list($threads, $showAdminOptions): string { $html = "". "". "". "". "". ""; if ($showAdminOptions) { $html .= ""; } $html .= ""; $current_post = 0; foreach ($threads as $thread) { $oe = ($current_post++ % 2 == 0) ? "even" : "odd"; global $config; $titleSubString = $config->get_int('forumTitleSubString'); if ($titleSubString < strlen($thread["title"])) { $title = substr($thread["title"], 0, $titleSubString); $title = $title."..."; } else { $title = $thread["title"]; } if (bool_escape($thread["sticky"])) { $sticky = "Sticky: "; } else { $sticky = ""; } $html .= "". '". '". "". ""; if ($showAdminOptions) { $html .= ''; } $html .= ""; } $html .= "
TitleAuthorUpdatedResponsesActions
'.$sticky.''.$title."'.$thread["user_name"]."".autodate($thread["uptodate"])."".$thread["response_count"]."Delete
"; return $html; } }