Skip to content

Commit

Permalink
Merge pull request #3799 from Spuds/topicTweaks
Browse files Browse the repository at this point in the history
Topic tweaks
  • Loading branch information
Spuds committed May 1, 2024
2 parents aaf8e65 + 0734603 commit 91c8ac5
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 59 deletions.
6 changes: 4 additions & 2 deletions sources/ElkArte/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public function increaseTopicViews($topic)
*
* @param int $topic
* @param int $board
* @throws \ElkArte\Exceptions\Exception on invalid topic value
* @throws Exception on invalid topic value
*/
public function loadTopicInfo($topic, $board)
{
Expand Down Expand Up @@ -583,6 +583,8 @@ public function setMessageContext()
$context['topic_last_message'] = $this->topicinfo['id_last_msg'];
$context['topic_unwatched'] = $this->topicinfo['unwatched'] ?? 0;
$context['start_from'] = $this->start_from;
$context['topic_start_time'] = htmlTime($this->topicinfo['poster_time']);
$context['topic_starter_name'] = $this->topicinfo['poster_name'];

// Did this user start the topic or not?
$context['user']['started'] = $this->didThisUserStart();
Expand Down Expand Up @@ -1015,7 +1017,7 @@ public function buildModerationButtons()
* @param string $action the function name of the current action
*
* @return bool
* @throws \ElkArte\Exceptions\Exception not_a_topic
* @throws Exception not_a_topic
*/
public function trackStats($action = '')
{
Expand Down
2 changes: 1 addition & 1 deletion sources/ElkArte/Http/CurlFetchWebdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private function _buildPostData($post_data)
// we don't support that.
foreach ($post_data as $name => $value)
{
$post_vars[] = $name . '=' . urlencode($value[0] === '@' ? '' : $value);
$post_vars[] = $name . '=' . urlencode(($value === '' || $value[0] === '@') ? '' : $value);
}

return implode('&', $post_vars);
Expand Down
10 changes: 5 additions & 5 deletions sources/subs/Members.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ function memberQuerySeeBoard($id_member)
* - If the member's post number is updated, updates their post groups.
*
* @param int[]|int $members An array of member ids
* @param mixed[] $data An associative array of the columns to be updated and their respective values.
* @param array $data An associative array of the columns to be updated and their respective values.
*/
function updateMemberData($members, $data)
{
Expand Down Expand Up @@ -2719,7 +2719,7 @@ function updateMemberData($members, $data)
if (!empty($modSettings['integrate_change_member_data']))
{
// Only a few member variables are really interesting for integration.
$integration_vars = array(
$integration_vars = [
'member_name',
'real_name',
'email_address',
Expand All @@ -2731,7 +2731,7 @@ function updateMemberData($members, $data)
'time_offset',
'avatar',
'lngfile',
);
];
$vars_to_integrate = array_intersect($integration_vars, array_keys($data));

// Only proceed if there are any variables left to call the integration function.
Expand All @@ -2740,7 +2740,7 @@ function updateMemberData($members, $data)
// Fetch a list of member_names if necessary
if ((!is_array($members) && $members === User::$info->id) || (is_array($members) && count($members) == 1 && in_array(User::$info->id, $members)))
{
$member_names = array(User::$info->username);
$member_names = [User::$info->username];
}
else
{
Expand Down Expand Up @@ -2797,7 +2797,7 @@ function ($row) {
{
if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
{
if ($match[1] != '+ ')
if ($match[1] !== '+ ')
{
$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
}
Expand Down
2 changes: 1 addition & 1 deletion sources/subs/Topic.subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ function getTopicInfo($topic_parameters, $full = '', $selects = array(), $tables
}

$messages_table = $full === 'message' || $full === 'all' || $full === 'starter';
$members_table = $full === 'starter';
$members_table = $full === 'starter' || $full === 'all';
$logs_table = $full === 'all';

// Create the query, taking full and integration in to account
Expand Down
9 changes: 5 additions & 4 deletions tests/ElkArte/Http/CurlFetchWebdataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected function setUp(): void
//),
array(
'https://duckduckgo.com/html',
array('q' => 'stargate+sg1 site:www.imdb.com', 'ia' => 'about'),
200,
array('q' => 'stargate+sg1 site:www.imdb.com', 'b' => ''),
[200, 403],
'TV Series',
),
);
Expand Down Expand Up @@ -105,9 +105,10 @@ public function testCurlPost()
// Check for correct fetch
if (!empty($testcase[2]))
{
$this->assertEquals($testcase[2], $curl->result('code'));
$this->assertContains($curl->result('code'), $testcase[2]);
}
if (!empty($testcase[3]))

if (!empty($testcase[3]) && $curl->result('code') == 200)
{
$this->assertStringContainsString($testcase[3], $curl->result('body'));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ElkArte/Http/FsockFetchWebdataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
array(
'https://www.elkarte.net/community/index.php?action=search;sa=results',
array('search' => 'stuff', 'search_selection' => 'all', 'advanced' => 0),
200,
[200, 403],
'let you access this section',
),
);
Expand Down Expand Up @@ -120,10 +120,10 @@ public function testFsockPost()
// Check for correct fetch
if (!empty($testcase[2]))
{
$this->assertEquals($testcase[2], $fsock->result('code'), 'PostCodeError:: ' . $testcase[0]);
$this->assertContains($fsock->result('code'), $testcase[2], 'PostCodeError:: ' . $testcase[0]);
}

if (!empty($testcase[3]))
if (!empty($testcase[3]) && $fsock->result('code') == 200)
{
$this->assertStringContainsString($testcase[3], $fsock->result('body'), 'PostBodyError:: ' . $testcase[0]);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ElkArte/Http/StreamFetchWebdataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ protected function setUp(): void
array(
'https://www.w3schools.com/action_page.php',
array('firstname' => 'elkarte', 'lastname' => 'forum'),
200,
[200, 403],
'firstname=elkarte&lastname=forum&nbsp;',
),
array(
'https://www.elkarte.net/community/index.php?action=search;sa=results',
array('search' => 'stuff', 'search_selection' => 'all', 'advanced' => 0),
200,
[200, 403],
'let you access this section',
),
);
Expand Down Expand Up @@ -113,10 +113,10 @@ public function testStreamPost()
// Check for correct fetch
if (!empty($testcase[2]))
{
$this->assertEquals($testcase[2], $fsock->result('code'), 'PostCodeError:: ' . $testcase[0]);
$this->assertContains($fsock->result('code'), $testcase[2], 'PostCodeError:: ' . $testcase[0]);
}

if (!empty($testcase[3]))
if (!empty($testcase[3]) && $fsock->result('code') == 200)
{
$this->assertStringContainsString($testcase[3], $fsock->result('body'), 'PostBodyError:: ' . $testcase[0]);
}
Expand Down
11 changes: 9 additions & 2 deletions themes/default/Display.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ function template_messages_informations_above()
{
global $context, $settings, $txt, $scripturl, $modSettings;

// Show the topic information - icon, subject, etc.
// Show the topic information - icon, subject, stats, etc.
echo '
<main id="forumposts">
<header class="category_header">
<i class="hdicon ', $context['class'], '"></i>
<span id="topic_subject">', $context['subject'], '</span>&nbsp;<span class="views_text">(', $context['num_views_text'], ')</span>
<span id="topic_subject">', $context['subject'], '</span>
<span class="stats_text">
<i class="icon icon-small i-user"></i>', $context['topic_starter_name'], '
<span>&middot;</span>
<i class="icon icon-small i-calendar"></i>', $context['topic_start_time'], '
<span>&middot;</span>
<i class="icon icon-small i-view"></i>', $context['num_views_text'], '
</span>
<span class="nextlinks">',
empty($context['links']['go_prev']) ? '' : '<a href="' . $context['links']['go_prev'] . '">' . $txt['previous_next_back'] . '</a>',
empty($context['links']['go_next']) ? '' : ' - <a href="' . $context['links']['go_next'] . '">' . $txt['previous_next_forward'] . '</a>',
Expand Down
2 changes: 1 addition & 1 deletion themes/default/css/_gold/index_gold.css
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ ul.cf_icons {
border-top-color: var(--infobox_border);
border-bottom-color: var(--infobox_border);
background-color: var(--infobox);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 77 77'%3E%3Cpath fill-rule='evenodd' d='M38.4 0c21.208 0 38.4 17.192 38.4 38.4S59.608 76.8 38.4 76.8 0 59.608 0 38.4 17.192 0 38.4 0Zm8.952 28.286c-1.141-1.183-2.713-1.598-4.37-1.578-2.208.026-4.567.826-6.254 1.612-4.038 1.881-7.136 5.212-9.717 8.773-.464.64-.707 1.398.11 1.988.698.503 1.2.053 1.62-.396l.028-.03.095-.102a59.44 59.44 0 0 0 1.384-1.57l.114-.132.114-.133c1.369-1.587 2.762-3.152 4.605-4.213 1.096-.632 1.886.343 1.717 1.438-.102.657-.447 1.275-.688 1.91-.858 2.254-1.728 4.504-2.595 6.755a681.974 681.974 0 0 0-2.817 7.416l-.08.215-.08.215c-.812 2.186-1.612 4.355-2.142 6.636-.423 1.824-.992 4.037-.174 5.828.471 1.032 1.47 1.741 2.583 1.903 1.516.22 3.156.245 4.64-.092a17.387 17.387 0 0 0 2.263-.68c2.265-.853 4.329-2.167 6.187-3.71 1.89-1.576 3.557-3.44 5.076-5.373.488-.62 1.08-1.308 1.247-2.103.156-.747-.51-1.812-1.373-1.38-.456.23-.798.795-1.13 1.172a66.91 66.91 0 0 1-1.271 1.396c-.86.92-1.74 1.819-2.625 2.714a7.15 7.15 0 0 1-1.907 1.35c-.864.424-1.551-.046-1.458-1.003.086-.878.3-1.765.602-2.597 1.212-3.347 2.448-6.685 3.673-10.027a927.144 927.144 0 0 0 2.28-6.273c.702-1.957 1.3-3.898 1.554-5.972.174-1.428-.196-2.906-1.211-3.957zm2.549-16.06c-3.654-1.422-8.01 1.004-8.743 4.87-.53 2.792.533 5.25 2.72 6.286 4.23 2.007 9.291-1.198 9.291-5.883 0-2.6-1.144-4.447-3.268-5.273z' style='stroke-width:.04;stroke:none;stroke-opacity:1;fill:%230000bc;fill-opacity:1'/%3E%3C/svg%3E");
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 77 77'%3E%3Cpath fill-rule='evenodd' d='M38.4 0c21.208 0 38.4 17.192 38.4 38.4S59.608 76.8 38.4 76.8 0 59.608 0 38.4 17.192 0 38.4 0Zm8.952 28.286c-1.141-1.183-2.713-1.598-4.37-1.578-2.208.026-4.567.826-6.254 1.612-4.038 1.881-7.136 5.212-9.717 8.773-.464.64-.707 1.398.11 1.988.698.503 1.2.053 1.62-.396l.028-.03.095-.102a59.44 59.44 0 0 0 1.384-1.57l.114-.132.114-.133c1.369-1.587 2.762-3.152 4.605-4.213 1.096-.632 1.886.343 1.717 1.438-.102.657-.447 1.275-.688 1.91-.858 2.254-1.728 4.504-2.595 6.755a681.974 681.974 0 0 0-2.817 7.416l-.08.215-.08.215c-.812 2.186-1.612 4.355-2.142 6.636-.423 1.824-.992 4.037-.174 5.828.471 1.032 1.47 1.741 2.583 1.903 1.516.22 3.156.245 4.64-.092a17.387 17.387 0 0 0 2.263-.68c2.265-.853 4.329-2.167 6.187-3.71 1.89-1.576 3.557-3.44 5.076-5.373.488-.62 1.08-1.308 1.247-2.103.156-.747-.51-1.812-1.373-1.38-.456.23-.798.795-1.13 1.172a66.91 66.91 0 0 1-1.271 1.396c-.86.92-1.74 1.819-2.625 2.714a7.15 7.15 0 0 1-1.907 1.35c-.864.424-1.551-.046-1.458-1.003.086-.878.3-1.765.602-2.597 1.212-3.347 2.448-6.685 3.673-10.027a927.144 927.144 0 0 0 2.28-6.273c.702-1.957 1.3-3.898 1.554-5.972.174-1.428-.196-2.906-1.211-3.957zm2.549-16.06c-3.654-1.422-8.01 1.004-8.743 4.87-.53 2.792.533 5.25 2.72 6.286 4.23 2.007 9.291-1.198 9.291-5.883 0-2.6-1.144-4.447-3.268-5.273z' style='stroke-width:.04;stroke:none;stroke-opacity:1;fill:%230000bc;fill-opacity:.55'/%3E%3C/svg%3E");
}

.errorbox {
Expand Down
2 changes: 1 addition & 1 deletion themes/default/css/_light/index_light.css
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ ul.cf_icons {
border-top-color: var(--infobox_border);
border-bottom-color: var(--infobox_border);
background-color: var(--infobox);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 77 77'%3E%3Cpath fill-rule='evenodd' d='M38.4 0c21.208 0 38.4 17.192 38.4 38.4S59.608 76.8 38.4 76.8 0 59.608 0 38.4 17.192 0 38.4 0Zm8.952 28.286c-1.141-1.183-2.713-1.598-4.37-1.578-2.208.026-4.567.826-6.254 1.612-4.038 1.881-7.136 5.212-9.717 8.773-.464.64-.707 1.398.11 1.988.698.503 1.2.053 1.62-.396l.028-.03.095-.102a59.44 59.44 0 0 0 1.384-1.57l.114-.132.114-.133c1.369-1.587 2.762-3.152 4.605-4.213 1.096-.632 1.886.343 1.717 1.438-.102.657-.447 1.275-.688 1.91-.858 2.254-1.728 4.504-2.595 6.755a681.974 681.974 0 0 0-2.817 7.416l-.08.215-.08.215c-.812 2.186-1.612 4.355-2.142 6.636-.423 1.824-.992 4.037-.174 5.828.471 1.032 1.47 1.741 2.583 1.903 1.516.22 3.156.245 4.64-.092a17.387 17.387 0 0 0 2.263-.68c2.265-.853 4.329-2.167 6.187-3.71 1.89-1.576 3.557-3.44 5.076-5.373.488-.62 1.08-1.308 1.247-2.103.156-.747-.51-1.812-1.373-1.38-.456.23-.798.795-1.13 1.172a66.91 66.91 0 0 1-1.271 1.396c-.86.92-1.74 1.819-2.625 2.714a7.15 7.15 0 0 1-1.907 1.35c-.864.424-1.551-.046-1.458-1.003.086-.878.3-1.765.602-2.597 1.212-3.347 2.448-6.685 3.673-10.027a927.144 927.144 0 0 0 2.28-6.273c.702-1.957 1.3-3.898 1.554-5.972.174-1.428-.196-2.906-1.211-3.957zm2.549-16.06c-3.654-1.422-8.01 1.004-8.743 4.87-.53 2.792.533 5.25 2.72 6.286 4.23 2.007 9.291-1.198 9.291-5.883 0-2.6-1.144-4.447-3.268-5.273z' style='stroke-width:.04;stroke:none;stroke-opacity:1;fill:%230000bc;fill-opacity:1'/%3E%3C/svg%3E");
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 77 77'%3E%3Cpath fill-rule='evenodd' d='M38.4 0c21.208 0 38.4 17.192 38.4 38.4S59.608 76.8 38.4 76.8 0 59.608 0 38.4 17.192 0 38.4 0Zm8.952 28.286c-1.141-1.183-2.713-1.598-4.37-1.578-2.208.026-4.567.826-6.254 1.612-4.038 1.881-7.136 5.212-9.717 8.773-.464.64-.707 1.398.11 1.988.698.503 1.2.053 1.62-.396l.028-.03.095-.102a59.44 59.44 0 0 0 1.384-1.57l.114-.132.114-.133c1.369-1.587 2.762-3.152 4.605-4.213 1.096-.632 1.886.343 1.717 1.438-.102.657-.447 1.275-.688 1.91-.858 2.254-1.728 4.504-2.595 6.755a681.974 681.974 0 0 0-2.817 7.416l-.08.215-.08.215c-.812 2.186-1.612 4.355-2.142 6.636-.423 1.824-.992 4.037-.174 5.828.471 1.032 1.47 1.741 2.583 1.903 1.516.22 3.156.245 4.64-.092a17.387 17.387 0 0 0 2.263-.68c2.265-.853 4.329-2.167 6.187-3.71 1.89-1.576 3.557-3.44 5.076-5.373.488-.62 1.08-1.308 1.247-2.103.156-.747-.51-1.812-1.373-1.38-.456.23-.798.795-1.13 1.172a66.91 66.91 0 0 1-1.271 1.396c-.86.92-1.74 1.819-2.625 2.714a7.15 7.15 0 0 1-1.907 1.35c-.864.424-1.551-.046-1.458-1.003.086-.878.3-1.765.602-2.597 1.212-3.347 2.448-6.685 3.673-10.027a927.144 927.144 0 0 0 2.28-6.273c.702-1.957 1.3-3.898 1.554-5.972.174-1.428-.196-2.906-1.211-3.957zm2.549-16.06c-3.654-1.422-8.01 1.004-8.743 4.87-.53 2.792.533 5.25 2.72 6.286 4.23 2.007 9.291-1.198 9.291-5.883 0-2.6-1.144-4.447-3.268-5.273z' style='stroke-width:.04;stroke:none;stroke-opacity:1;fill:%230000bc;fill-opacity:.55'/%3E%3C/svg%3E");
}

.errorbox {
Expand Down
4 changes: 3 additions & 1 deletion themes/default/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ h3.category_header form {

/* Styles for the admin home screen. */
#quick_search {
order: 2;
margin-top: -.2rem;
margin-left: auto;
}

.admincenter .well, #modcenter .well {
Expand Down Expand Up @@ -1229,8 +1231,8 @@ dl.themes_list dd {
}

#core_features .features {
width: 100%;
float: none;
width: 100%;
}

#core_features .features_switch {
Expand Down
52 changes: 43 additions & 9 deletions themes/default/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ h2.hdicon {
margin: 0 .6rem 0 0;
content: "";
vertical-align: text-bottom;
line-height: 1.8rem;
}

/* Expand/Collapse image in the various headers */
Expand Down Expand Up @@ -2886,6 +2887,7 @@ aside.poster, #quickreplybox .poster {
display: flex;
align-items: center;
flex-direction: column;
padding-top: .4rem;
}

/* li lines in poster, could use flex / flex row here */
Expand Down Expand Up @@ -3285,26 +3287,50 @@ aside.poster, #quickreplybox .poster {
border-radius: .4rem .4rem 0 0;
}

/* The area at the top of each topic page, icon, title, views, links */
#forumposts .category_header {
overflow: hidden;
text-overflow: ellipsis;
display: flex;
align-items: center;
display: grid;
grid-template-columns: 3rem auto 1fr;
grid-template-rows: 4rem auto;
grid-template-areas:
"hdicon subject subject"
". stats navigation";
}

/* Topic icon and title */
#forumposts .hdicon {
align-self: center;
grid-area: hdicon;
height: 2.2rem;
}

/* Number of views and previous /next links in the category header */
#forumposts .hdicon::before {
vertical-align: initial;
}

#topic_subject {
align-self: center;
grid-area: subject;
font-size: var(--font22);
}

/* Number of views and previous / next links in the category header */
.nextlinks {
font-size: var(--font15);
margin-left: auto;
white-space: pre;
justify-self: end;
grid-area: navigation;
}

.views_text {
.stats_text {
font-size: var(--font13);
white-space: pre;
opacity: .85;
place-self: start center;
grid-area: stats;
}

/* Used a spacer between posts */
/* Used as a spacer between posts */
.forumposts {
margin-top: .13em;
border: 1px solid;
Expand Down Expand Up @@ -6127,7 +6153,15 @@ div.labels {
max-width: 45%;
}

#forumposts .views_text {
#forumposts .category_header {
grid-template-columns: auto 1fr;
grid-template-rows: 4rem auto;
grid-template-areas:
"subject subject"
"stats navigation";
}

#forumposts .views_text, #forumposts .category_header .hdicon {
display: none;
}

Expand Down
37 changes: 12 additions & 25 deletions themes/default/scripts/script_elk.js
Original file line number Diff line number Diff line change
Expand Up @@ -919,14 +919,17 @@ const ElkNotifier = new window.ElkNotifications({});
},
showBar = function() {
clearTimeout(time_out);
elem.style.opacity = '1';

if (settings.hide_delay !== 0)
{
time_out = setTimeout(function() {
hide();
}, settings.hide_delay);
}
elem.fadeIn(250, function() {
if (settings.hide_delay !== 0)
{
// This will clear the bar if hide has not been implicitly called
time_out = setTimeout(function() {
hide();
}, settings.hide_delay);
}
});

return this;
},
isError = function() {
Expand All @@ -940,7 +943,7 @@ const ElkNotifier = new window.ElkNotifications({});
hide = function() {
// Short delay to avoid removing opacity while it is still be added
window.setTimeout(function() {
elem.style.opacity = '0';
elem.fadeOut(300);
}, 300);

clearTimeout(time_out);
Expand All @@ -961,23 +964,7 @@ const ElkNotifier = new window.ElkNotifications({});
};
});

// AMD / RequireJS
if (typeof define !== 'undefined' && define.amd)
{
define([], function() {
return ElkInfoBar;
});
}
// CommonJS
else if (typeof module !== 'undefined' && module.exports)
{
module.exports = ElkInfoBar;
}
// included directly via <script> tag
else
{
this.ElkInfoBar = ElkInfoBar;
}
this.ElkInfoBar = ElkInfoBar;
})();

/**
Expand Down

0 comments on commit 91c8ac5

Please sign in to comment.