diff --git a/topic-count-in-profiles/Subs-TCIP.php b/topic-count-in-profiles/Subs-TCIP.php new file mode 100644 index 0000000..a45ef1c --- /dev/null +++ b/topic-count-in-profiles/Subs-TCIP.php @@ -0,0 +1,82 @@ + $memID, + 'time_offset' => $user_info['time_offset'] * 3600, + ) + ); + $maxPosts = $realPosts = 0; + $num_topics_by_time = array(); + $context['topics_by_time'] = array(); + while ([$hour, $num] = $smcFunc['db_fetch_row']($result)) + { + $maxPosts = max($num, $maxPosts); + $realPosts += $num; + + $num_topics_by_time[$hour] = $num; + } + $smcFunc['db_free_result']($result); + + if ($maxPosts > 0) + for ($hour = 0; $hour < 24; $hour++) + { + $context['topics_by_time'][$hour] = array( + 'hour' => $hour, + 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), + 'posts' => 0, + 'posts_percent' => 0, + 'relative_percent' => 0, + 'is_last' => $hour == 23, + ); + + if (isset($num_topics_by_time[$hour])) + { + $context['topics_by_time'][$hour]['posts'] = $num_topics_by_time[$hour]; + $context['topics_by_time'][$hour]['posts_percent'] = round(($num_topics_by_time[$hour] * 100) / $realPosts); + $context['topics_by_time'][$hour]['relative_percent'] = round(($num_topics_by_time[$hour] * 100) / $maxPosts); + } + } + loadLanguage('TCIP'); + } +} \ No newline at end of file diff --git a/topic-count-in-profiles/TCIP.english.php b/topic-count-in-profiles/TCIP.english.php new file mode 100644 index 0000000..67bad1c --- /dev/null +++ b/topic-count-in-profiles/TCIP.english.php @@ -0,0 +1,10 @@ + + + + runic:Topic_Count_In_Profile + 2.1 + + + + + count($new_loaded_ids) == 1 ? $new_loaded_ids[0] : $new_loaded_ids, + ) + ); + while ($row = $smcFunc['db_fetch_assoc']($request)) + $user_profile[$row['id_member_started']]['topics'] = $row['topics']; + $smcFunc['db_free_result']($request); + + $request = $smcFunc['db_query']('', ' + SELECT id_member, COUNT(DISTINCT id_topic) AS topic_count + FROM {db_prefix}messages + WHERE id_member' . (count($new_loaded_ids) == 1 ? ' = {int:loaded_ids}' : ' IN ({array_int:loaded_ids})') . ' + GROUP BY id_member', + array( + 'loaded_ids' => count($new_loaded_ids) == 1 ? $new_loaded_ids[0] : $new_loaded_ids, + ) + ); + while ($row = $smcFunc['db_fetch_assoc']($request)) + $user_profile[$row['id_member']]['topic_count'] = $row['topic_count']; + $smcFunc['db_free_result']($request); + } + +]]> + + + $profile['posts'],]]> + (isset($profile['topics']) ? comma_format($profile['topics']) : 0), + 'topic_count' => (isset($profile['topic_count']) ? comma_format($profile['topic_count']) : 0),]]> + + + + + + + + + + 100000 ? ' + AND id_topic > {int:top_ten_thousand_topics}' : '') . ' + GROUP BY hour', + array( + 'current_member' => $memID, + 'top_ten_thousand_topics' => $modSettings['totalTopics'] - 10000, + 'time_offset' => (($user_info['time_offset'] + $modSettings['time_offset']) * 3600), + ) + ); + $maxPosts = 0; + $context['posts_by_time'] = array(); + while ($row = $smcFunc['db_fetch_assoc']($result)) + { + // Cast as an integer to remove the leading 0. + $row['hour'] = (int) $row['hour']; + + if ($row['post_count'] > $maxPosts) + $maxPosts = $row['post_count']; + + $context['posts_by_time'][$row['hour']] = array( + 'hour' => $row['hour'], + 'posts_percent' => $row['post_count'] + ); + } + $smcFunc['db_free_result']($result); + + if ($maxPosts > 0) + for ($hour = 0; $hour < 24; $hour++) + { + if (!isset($context['posts_by_time'][$hour])) + $context['posts_by_time'][$hour] = array( + 'hour' => $hour, + 'posts_percent' => 0, + ); + else + $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts_percent'] * 100) / $maxPosts); + } + + // Put it in the right order. + ksort($context['posts_by_time']); +]]> + 100000 ? ' + AND m.id_topic > {int:top_ten_thousand_topics}' : '') . ' + GROUP BY hour', + array( + 'current_member' => $memID, + 'top_ten_thousand_topics' => $modSettings['totalTopics'] - 10000, + 'time_offset' => (($user_info['time_offset'] + $modSettings['time_offset']) * 3600), + ) + ); + $maxPosts = 0; + $context['topics_by_time'] = array(); + while ($row = $smcFunc['db_fetch_assoc']($result)) + { + // Cast as an integer to remove the leading 0. + $row['hour'] = (int) $row['hour']; + + if ($row['post_count'] > $maxPosts) + $maxPosts = $row['post_count']; + + $context['topics_by_time'][$row['hour']] = array( + 'hour' => $row['hour'], + 'posts_percent' => $row['post_count'] + ); + } + $smcFunc['db_free_result']($result); + + if ($maxPosts > 0) + for ($hour = 0; $hour < 24; $hour++) + { + if (!isset($context['topics_by_time'][$hour])) + $context['topics_by_time'][$hour] = array( + 'hour' => $hour, + 'posts_percent' => 0, + ); + else + $context['topics_by_time'][$hour]['posts_percent'] = round(($context['topics_by_time'][$hour]['posts_percent'] * 100) / $maxPosts); + } + loadLanguage('TCIP'); + + // Put it in the right order. + ksort($context['topics_by_time']); + +]]> + + + + + + ', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')';]]> + ', $txt['profile_topics_started'], ': +
', $context['member']['topics'], ' (', $context['member']['topics_per_day'], ' ', $txt['posts_per_day'], ')
+
', $txt['profile_topics_participated'], ':
+
', $context['member']['topic_count'], '
'; +]]>
+
+ + '; + + // The labels. + foreach ($context['posts_by_time'] as $time_of_day) + echo ' +
', date('g a', mktime($time_of_day['hour'])), '
+
', !empty($time_of_day['posts_percent']) ? '
' . $time_of_day['posts_percent'] . '%' : '', '
'; + echo ' + ';]]>
+ ', $txt['tcip_posts'] ,'

+
'; + + // The labels. + foreach ($context['posts_by_time'] as $time_of_day) + echo ' +
', date('g a', mktime($time_of_day['hour'])), '
+
', !empty($time_of_day['posts_percent']) ? '
' . $time_of_day['posts_percent'] . '%' : '', '
'; + echo ' +
+


', $txt['tcip_topics'] ,'

+
'; + + // The labels. + foreach ($context['topics_by_time'] as $time_of_day) + echo ' +
', date('g a', mktime($time_of_day['hour'])), '
+
', !empty($time_of_day['posts_percent']) ? '
' . $time_of_day['posts_percent'] . '%' : '', '
'; + echo ' +
'; + +]]>
+
+
+
diff --git a/topic-count-in-profiles/install21.xml b/topic-count-in-profiles/install21.xml new file mode 100644 index 0000000..9e716dd --- /dev/null +++ b/topic-count-in-profiles/install21.xml @@ -0,0 +1,124 @@ + + + + runic:Topic_Count_In_Profile + 2.1 + + + + + count($new_loaded_ids) == 1 ? $new_loaded_ids[0] : $new_loaded_ids, + ) + ); + while ($row = $smcFunc['db_fetch_assoc']($request)) + $user_profile[$row['id_member_started']]['topics'] = $row['topics']; + $smcFunc['db_free_result']($request); + + $request = $smcFunc['db_query']('', ' + SELECT id_member, COUNT(DISTINCT id_topic) AS topic_count + FROM {db_prefix}messages + WHERE id_member' . (count($new_loaded_ids) == 1 ? ' = {int:loaded_ids}' : ' IN ({array_int:loaded_ids})') . ' + GROUP BY id_member', + array( + 'loaded_ids' => count($new_loaded_ids) == 1 ? $new_loaded_ids[0] : $new_loaded_ids, + ) + ); + while ($row = $smcFunc['db_fetch_assoc']($request)) + $user_profile[$row['id_member']]['topic_count'] = $row['topic_count']; + $smcFunc['db_free_result']($request); + } + +]]> + + + $profile['posts'],]]> + (isset($profile['topics']) ? comma_format($profile['topics']) : 0), + 'topic_count' => (isset($profile['topic_count']) ? comma_format($profile['topic_count']) : 0),]]> + + + + + + ', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')';]]> + ', $txt['profile_topics_started'], ': +
', $context['member']['topics'], ' (', $context['member']['topics_per_day'], ' ', $txt['posts_per_day'], ')
+
', $txt['profile_topics_participated'], ':
+
', $context['member']['topic_count'], '
'; +]]>
+
+ + '; + + // The labels. + foreach ($context['posts_by_time'] as $time_of_day) + echo ' +
  • +
    +
    + ', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), ' +
    +
    + ', $time_of_day['hour_format'], ' +
  • '; + + echo ' + ';]]>
    + ', $txt['tcip_posts'] ,'

    +
      '; + + // The labels. + foreach ($context['posts_by_time'] as $time_of_day) + echo ' +
    • +
      +
      + ', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), ' +
      +
      + ', $time_of_day['hour_format'], ' +
    • '; + + echo ' +
    +


    ', $txt['tcip_topics'] ,'

    +
      '; + + // The labels. + foreach ($context['topics_by_time'] as $time_of_day) + echo ' +
    • +
      +
      + ', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), ' +
      +
      + ', $time_of_day['hour_format'], ' +
    • '; + + echo ' +
    ';]]>
    +
    +
    + +
    diff --git a/topic-count-in-profiles/package-info.xml b/topic-count-in-profiles/package-info.xml new file mode 100644 index 0000000..7c12215 --- /dev/null +++ b/topic-count-in-profiles/package-info.xml @@ -0,0 +1,60 @@ + + + + live627:tcip + Topic Count in Profiles + 3.0.0 + modification + + + ]]> + install20.xml + + + + + + install20.xml + + + + + + ]]> + install21.xml + + + + + + + + install21.xml + + + + + + \ No newline at end of file