From 631dab31556a5d5ca2aa3eab9aace1a78594005b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 6 Aug 2024 16:04:55 -0700 Subject: [PATCH 1/2] web: forum and PM cleanup - don't use tables when they're not needed. In light mode, bootstrap puts noisy lines around them - use constants PM_LH_PCT and FORUM_LH_PCT for width of left (informational) column. - show lists of posts (user posts, search results) in 2-column format - use functions like row2() rather than ... - forums: show header (search box, PM links) only in top-level pages. Not needed on e.g. form for posting a message - change page titles to say what you're looking at (forum, thread) - use sprintf() instead of long concatenations - make terminology consistent: you 'post' to a thread or you 'reply' to a message. You don't reply to a thread. --- html/inc/bbcode_html.inc | 83 +++++++++++++++---------------- html/inc/forum.inc | 42 ++++++++-------- html/inc/pm.inc | 75 ++++++++++++++++------------ html/inc/text_transform.inc | 17 +++---- html/user/forum_edit.php | 83 +++++++++++++++++-------------- html/user/forum_forum.php | 6 +-- html/user/forum_post.php | 61 +++++++++++++++++------ html/user/forum_reply.php | 28 +++++++---- html/user/forum_search_action.php | 3 +- html/user/forum_thread.php | 4 +- html/user/forum_user_posts.php | 3 +- 11 files changed, 227 insertions(+), 178 deletions(-) diff --git a/html/inc/bbcode_html.inc b/html/inc/bbcode_html.inc index a5bf352815d..f1118fe9403 100644 --- a/html/inc/bbcode_html.inc +++ b/html/inc/bbcode_html.inc @@ -5,47 +5,44 @@ require_once("../inc/util.inc"); $bbcode_js = ""; $bbcode_html = ' - - - - - - - - - - - - - - - - -  '.tra("Font color").': - -  '.tra("Font size").': - -   - '.tra("Close Tags").' - - +

+ + + + + + + + + + +

+  '.tra("Font color").': + +  '.tra("Font size").': + +   + '.tra("Close Tags").' +

'; + +?> diff --git a/html/inc/forum.inc b/html/inc/forum.inc index 674ac440762..9c7a2e423c2 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -24,6 +24,7 @@ require_once("../inc/news.inc"); require_once("../inc/text_transform.inc"); define('THREADS_PER_PAGE', 50); +define('FORUM_LH_PCT', '25%'); // width of LH column $forum_error = ""; // for functions that return null on error, @@ -192,11 +193,11 @@ function forum_title($category, $forum, $thread, $link_thread=false) { $forum->title ); } else if ($forum && $thread) { - $x .= sprintf('%s :', + $x .= sprintf('%s : ', $top_url, $where ); - $x .= sprintf('%s :', + $x .= sprintf('%s : ', $forum->id, $forum->title ); @@ -781,30 +782,29 @@ function show_post_and_context($post, $thread, $forum, $options, $n) { } else { $deleted = ""; } - echo " - - - $n) - "; switch ($forum->parent_type) { case 0: $category = BoincCategory::lookup_id($forum->category); - echo forum_title($category, $forum, $thread, true); + $title= forum_title($category, $forum, $thread, true); break; case 1: - echo team_forum_title($forum); + $title= team_forum_title($forum); break; } - echo " - (id."&postid=".$post->id."\">".tra("Message %1", $post->id).") -
- ".tra("Posted %1 by %2", $when, user_links($user))." $deleted -
- Post: -


+ row_array([ + sprintf( + '%d) %s +
%s +
%s%s + ', + $n, $title, + $thread->id, $post->id, + tra("Message %1", $post->id), + tra("Posted %1 by %2", $when, user_links($user)), + $deleted + ), $content - - "; + ]); } function is_banished($user) { @@ -858,9 +858,7 @@ function post_rules() { } function post_warning($forum=null) { - $x = "

-
- "; + $x = '

'; // let projects add extra instructions in specific forums, // e.g. Questions and Problems @@ -873,7 +871,7 @@ function post_warning($forum=null) { ".post_rules()." -
+ "; return $x; } diff --git a/html/inc/pm.inc b/html/inc/pm.inc index 9d489ab1948..b20d6d3fe5c 100644 --- a/html/inc/pm.inc +++ b/html/inc/pm.inc @@ -20,6 +20,8 @@ require_once("boinc_db.inc"); require_once("sanitize_html.inc"); require_once("bbcode_html.inc"); +define('PM_LH_PCT', '30%'); + function pm_header() { echo "
\n"; echo " ".tra("Inbox")."\n"; @@ -29,7 +31,7 @@ function pm_header() { function pm_rules() { if (defined('PM_RULES')) return PM_RULES; - $x = "
"; + $x = '

'; $x .= tra("

  • Messages may not contain content that is obscene, hate-related, @@ -45,7 +47,7 @@ function pm_rules() {
  • If your account is suspended, don't create a new one.
"); - $x .= "
\n"; + $x .= ""; return $x; } @@ -82,25 +84,25 @@ function pm_team_form($user, $teamid, $error=null) { row2( tra("Subject"), "", - null, '20%' + null, PM_LH_PCT ); - row2_init(tra("Message")."".bbcode_info()."", '20%'); - start_table(); - echo $bbcode_html; - echo "\n"; - echo ""; - echo "\n"; - end_table(); - echo sprintf( - ' - - - - ', - button_style('blue'), - tra("Preview"), - button_style(), - tra("Send message") + row2( + tra("Message")."".bbcode_info()."", + $bbcode_html."", + null, PM_LH_PCT + ); + row2( + '', + sprintf( + ' + + ', + button_style('blue'), + tra("Preview"), + button_style(), + tra("Send message") + ), + null, PM_LH_PCT ); end_table(); page_tail(); @@ -174,24 +176,33 @@ function pm_form_page($replyto, $userid, $error = null) { '', $writeto ), - null, '20%' + null, PM_LH_PCT ); row2( tra("Subject"), - "", - null, '20%' + "", + null, PM_LH_PCT ); - row2_init( + row2( tra("Message")."".bbcode_info().pm_rules()."", - '20%' + sprintf( + '%s ', + $bbcode_html, + $content + ), + null, PM_LH_PCT + ); + row2( + '', + sprintf( + ' + + ', + tra("Preview"), + tra("Send message") + ), + null, PM_LH_PCT ); - start_table(); - echo $bbcode_html; - echo "\n"; - echo ""; - echo "\n"; - end_table(); - echo " \n"; end_table(); page_tail(); diff --git a/html/inc/text_transform.inc b/html/inc/text_transform.inc index 99e3d9e75f9..b208782064f 100644 --- a/html/inc/text_transform.inc +++ b/html/inc/text_transform.inc @@ -296,12 +296,12 @@ function externalize_links($text) { $linkpos=true; $out = ""; while (true){ - //Find a link + // Find a link // $linkpos=strpos($text, ". -// Using this page you can edit a post. -// First it displays a box to edit in, and when you submit the changes -// it will call the methods on the post to make the changes. -// +// Edit a post. +// The creator of the post can do this up to MAXIMUM_EDIT_TIME require_once('../inc/forum.inc'); require_once('../inc/bbcode_html.inc'); @@ -91,7 +89,6 @@ page_head(tra("Edit post"),'','','', $bbcode_js); -show_forum_header($logged_in_user); switch ($forum->parent_type) { case 0: $category = BoincCategory::lookup_id($forum->category); @@ -112,45 +109,59 @@ function() use($content) { ); } -echo "
id."\" method=\"POST\" name=\"post\" onsubmit=\"return checkForm(this)\">\n"; +echo sprintf( + '', + $post->id +); echo form_tokens($logged_in_user->authenticator); start_table(); row1(tra("Edit your message")); if ($can_edit_title) { - //If this is the user can edit the thread title display a way of doing so - if ($preview) { - row2( - tra("Title").bbcode_info(), - "" - ); - } else { - row2( - tra("Title").bbcode_info(), - '' - ); - } -}; - -if ($preview) { row2( - tra("Message").bbcode_info().post_warning(), - start_table_str().$bbcode_html.end_table_str()."" - ); -} else { - row2( - tra("Message").bbcode_info().post_warning(), - start_table_str().$bbcode_html.end_table_str().'' + tra("Title").bbcode_info(), + sprintf( + '', + 80, + htmlspecialchars($preview?$title:$thread->title) + ), + null, FORUM_LH_PCT ); } -if ($post->signature) { - $enable_signature="checked=\"true\""; -} else { - $enable_signature=""; -} -row2("", " - "); -row2("", " " +row2( + sprintf('%s %s %s', + tra("Message"), + bbcode_info(), + post_warning() + ), + sprintf( + '%s ', + $bbcode_html, + 12, + 80, + htmlspecialchars($preview?$content:$post->content) + ), + null, FORUM_LH_PCT +); + +row2("", + sprintf( + ' + + ', + $post->signature?'checked="true"':'', + tra("Add my signature to this post") + ), + null, FORUM_LH_PCT +); +row2("", + sprintf( + ' +   + ', + tra("Preview") + ), + null, FORUM_LH_PCT ); end_table(); diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 3b0ab7ba866..234bc661145 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -67,11 +67,7 @@ function forum_page($forum, $user, $msg=null) { switch ($forum->parent_type) { case 0: $category = BoincCategory::lookup_id($forum->category); - if ($category->is_helpdesk) { - page_head(tra("Questions and Answers").' : '.$forum->title); - } else { - page_head(tra("Message boards").' : '.$forum->title); - } + page_head(sprintf("%s '%s'", tra("Forum"), $forum->title)); if ($msg) echo "

$msg

\n"; show_forum_header($user); echo forum_title($category, $forum, NULL); diff --git a/html/user/forum_post.php b/html/user/forum_post.php index 22bef9e12b6..4122269ac89 100644 --- a/html/user/forum_post.php +++ b/html/user/forum_post.php @@ -120,23 +120,34 @@ function() use($content, $title) { } if ($force_title && $title){ - row2(tra("Title"), htmlspecialchars($title).""); + row2( + tra("Title"), + sprintf( + '%s ', + htmlspecialchars($title), + htmlspecialchars($title) + ), + null, FORUM_LH_PCT + ); } else { - row2(tra("Title").$submit_help, + row2( + tra("Title").$submit_help, sprintf('', $title?htmlspecialchars($title):'' - ) + ), + null, FORUM_LH_PCT ); } -row2_init(tra("Message").bbcode_info().post_warning($forum).$body_help); -start_table(); -echo $bbcode_html; -end_table(); -echo sprintf('', - $content?htmlspecialchars($content):'' +row2( + tra("Message").bbcode_info().post_warning($forum).$body_help, + sprintf( + '%s ', + $bbcode_html, + $content?htmlspecialchars($content):'' + ), + null, FORUM_LH_PCT ); -echo ""; if (!$logged_in_user->prefs->no_signature_by_default) { $enable_signature="checked=\"true\""; @@ -145,11 +156,33 @@ function() use($content, $title) { } if (is_news_forum($forum)) { - row2("", " ".tra("Show this item as a Notice in the BOINC Manager")."

".tra("Do so only for items likely to be of interest to all volunteers.")."

"); + row2("", + sprintf( + ' %s +

%s

', + tra("Show this item as a Notice in the BOINC Manager"), + tra("Do so only for items likely to be of interest to all volunteers.") + ), + null, FORUM_LH_PCT + ); } -row2("", " ".tra("Add my signature to this post")); -row2("", " "); - +row2("", + sprintf( + ' %s', + $enable_signature, + tra("Add my signature to this post") + ), + null, FORUM_LH_PCT +); +row2("", + sprintf( + ' + ', + tra("Preview"), + tra("OK") + ), + null, FORUM_LH_PCT +); end_table(); diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index 0449173fa86..066b9ecac83 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -16,8 +16,11 @@ // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . -// Post a reply to a thread. -// Both input (form) and action take place here. +// Post to a thread (possibly replying to an existing post). +// Both form and action are here. +// +// Note: the filename is confusing: +// we "reply" to a post, not a thread require_once('../inc/util.inc'); require_once('../inc/forum_email.inc'); @@ -91,9 +94,15 @@ } } -page_head(tra("Post to thread"),'','','', $bbcode_js); +page_head(tra("Post to thread")." '$thread->title'",'','','', $bbcode_js); -show_forum_header($logged_in_user); +if ($parent_post) { + echo sprintf( + '

Replying to message %d

', + $parent_post->id, + $parent_post->id + ); +} if ($warning) { echo "

$warning

"; @@ -144,9 +153,6 @@ function show_message_row($thread, $parent_post) { $x1 = tra("Message:").bbcode_info().post_warning(); $x2 = ""; - if ($parent_post) { - $x2 .=" ".tra("reply to %1 Message ID %2:", "id.">", " ".$parent_post->id.""); - } $x2 .= "id; if ($parent_post) { @@ -155,7 +161,7 @@ function show_message_row($thread, $parent_post) { $x2 .= " method=\"post\" name=\"post\" onsubmit=\"return checkForm(this)\">\n"; $x2 .= form_tokens($logged_in_user->authenticator); - $x2 .= start_table_str().$bbcode_html.end_table_str()."