Skip to content

Commit

Permalink
Merge pull request #4921 from Yoshi2889/profilestatsupdates
Browse files Browse the repository at this point in the history
Various updates to the profile's statistics page
  • Loading branch information
jdarwood007 committed Aug 15, 2018
2 parents eb3630c + dd9d2fd commit 0fb836b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
32 changes: 31 additions & 1 deletion Sources/Profile-View.php
Expand Up @@ -1456,8 +1456,38 @@ function statPanel($memID)
// Put it in the right order.
ksort($context['posts_by_time']);

/**
* Adding new entries:
* 'key' => array(
* 'text' => string, // The text that will be shown next to the entry.
* 'url' => string, // OPTIONAL: The entry will be a url
* ),
*
* 'key' will be used to look up the language string as $txt['statPanel_' . $key].
* Make sure to add a new entry when writing your mod!
*/
$context['text_stats'] = array(
'total_time_online' => array(
'text' => $context['time_logged_in'],
),
'total_posts' => array(
'text' => $context['num_posts'] . ' ' . $txt['statPanel_posts'],
'url' => $scripturl . '?action=profile;area=showposts;sa=messages;u=' . $memID
),
'total_topics' => array(
'text' => $context['num_topics'] . ' ' . $txt['statPanel_topics'],
'url' => $scripturl . '?action=profile;area=showposts;sa=topics;u=' . $memID
),
'users_polls' => array(
'text' => $context['num_polls'] . ' ' . $txt['statPanel_polls'],
),
'users_votes' => array(
'text' => $context['num_votes'] . ' ' . $txt['statPanel_votes']
)
);

// Custom stats (just add a template_layer to add it to the template!)
call_integration_hook('integrate_profile_stats', array($memID));
call_integration_hook('integrate_profile_stats', array($memID, &$context['text_stats']));
}

/**
Expand Down
29 changes: 17 additions & 12 deletions Themes/default/Profile.template.php
Expand Up @@ -1287,19 +1287,24 @@ function template_statPanel()

// First, show a few text statistics such as post/topic count.
echo '
<div id="profileview" class="roundframe">
<div id="profileview" class="roundframe noup">
<div id="generalstats">
<dl class="stats">
<dt>', $txt['statPanel_total_time_online'], ':</dt>
<dd>', $context['time_logged_in'], '</dd>
<dt>', $txt['statPanel_total_posts'], ':</dt>
<dd>', $context['num_posts'], ' ', $txt['statPanel_posts'], '</dd>
<dt>', $txt['statPanel_total_topics'], ':</dt>
<dd>', $context['num_topics'], ' ', $txt['statPanel_topics'], '</dd>
<dt>', $txt['statPanel_users_polls'], ':</dt>
<dd>', $context['num_polls'], ' ', $txt['statPanel_polls'], '</dd>
<dt>', $txt['statPanel_users_votes'], ':</dt>
<dd>', $context['num_votes'], ' ', $txt['statPanel_votes'], '</dd>
<dl class="stats">';

foreach ($context['text_stats'] as $key => $stat)
{
echo '
<dt>', $txt['statPanel_' . $key], '</dt>';

if (!empty($stat['url']))
echo '
<dd><a href="', $stat['url'], '">', $stat['text'], '</a></dd>';
else
echo '
<dd>', $stat['text'], '</dd>';
}

echo '
</dl>
</div>';

Expand Down

0 comments on commit 0fb836b

Please sign in to comment.