Skip to content

Commit

Permalink
* Rewrote Recent Items to use the time tag instead of these convolute…
Browse files Browse the repository at this point in the history
…d timestamp manipulations... (recent_items/*)

Signed-off-by: Nao <nao@wedge>
  • Loading branch information
Nao committed Sep 11, 2014
1 parent e8fc95e commit e5364fb
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 29 deletions.
1 change: 0 additions & 1 deletion recent_items/Recent-Admin.english.php
Expand Up @@ -6,4 +6,3 @@
$txt['recentitems_as_post'] = 'The most recently updated posts';
$txt['recentitems_as_topic'] = 'The most recently updated topics';
$txt['recentitems_sidebar_infocenter'] = 'Show recent items in the info-center?';
?>
1 change: 0 additions & 1 deletion recent_items/Recent-Admin.german.php
Expand Up @@ -6,4 +6,3 @@
$txt['recentitems_as_post'] = 'Die neuesten Beiträge';
$txt['recentitems_as_topic'] = 'Die neuesten Themen';
$txt['recentitems_sidebar_infocenter'] = 'Neue Beiträge im Info-Center zeigen?';
?>
2 changes: 0 additions & 2 deletions recent_items/Recent-Main.english.php
Expand Up @@ -2,5 +2,3 @@

$txt['recent_items_post'] = 'Recent Posts';
$txt['recent_items_topic'] = 'Recent Topics';

?>
2 changes: 0 additions & 2 deletions recent_items/Recent-Main.german.php
Expand Up @@ -2,5 +2,3 @@

$txt['recent_items_post'] = 'Neue Beiträge';
$txt['recent_items_topic'] = 'Neue Themen';

?>
23 changes: 5 additions & 18 deletions recent_items/Recent-Main.php
Expand Up @@ -25,24 +25,15 @@ function recentitems_common()
if (isset($context['latest_posts']))
return;

loadPluginTemplate('Arantor:RecentItems', 'Recent');
loadPluginLanguage('Arantor:RecentItems', 'Recent-Main');
loadPluginTemplate('Wedge:RecentItems', 'Recent');
loadPluginLanguage('Wedge:RecentItems', 'Recent-Main');

if (empty($settings['recentitems_posttopic']) || ($settings['recentitems_posttopic'] != 'post' && $settings['recentitems_posttopic'] != 'topic'))
$settings['recentitems_posttopic'] = 'post';

$temp = cache_get_data('boards-latest_' . $settings['recentitems_posttopic'] . ':' . md5(we::$user['query_wanna_see_board'] . we::$user['language']), 90);
if ($temp !== null)
{
// Before we just throw it at the user, reformat the time. It will have been cached with whatever format the user had at the time.
$context['latest_posts'] = $temp;
foreach ($context['latest_posts'] as $k => $post)
{
$context['latest_posts'][$k]['time'] = timeformat($post['raw_timestamp']);
$context['latest_posts'][$k]['timestamp'] = forum_time(true, $post['raw_timestamp']);
}
$context['latest_posts'] = cache_get_data('boards-latest_' . $settings['recentitems_posttopic'] . ':' . md5(we::$user['query_wanna_see_board'] . we::$user['language']), 90);
if ($context['latest_posts'] !== null)
return;
}

// First, get the message ids.
$context['latest_posts'] = array();
Expand Down Expand Up @@ -131,9 +122,7 @@ function recentitems_common()
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'raw_timestamp' => $row['poster_time'],
'timestamp' => $row['poster_time'],
'href' => '<URL>?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
'link' => '<a href="<URL>?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>'
);
Expand All @@ -143,5 +132,3 @@ function recentitems_common()

cache_put_data('boards-latest_' . $settings['recentitems_posttopic'] . ':' . md5(we::$user['query_wanna_see_board'] . we::$user['language']), $context['latest_posts'], 90);
}

?>
4 changes: 1 addition & 3 deletions recent_items/Recent.template.php
Expand Up @@ -21,11 +21,9 @@ function template_recentitems_infocenter()
foreach ($context['latest_posts'] as $post)
echo '
<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
<dd>', $post['time'], '</dd>';
<dd>', time_tag($post['timestamp']), '</dd>';

echo '
</dl>
</section>';
}

?>
4 changes: 2 additions & 2 deletions recent_items/plugin-info.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" standalone="yes" ?>
<plugin id="Arantor:RecentItems">
<plugin id="Wedge:RecentItems">
<name>Recent Items</name>
<author>Arantor</author>
<author>Wedge Team</author>
<description>Displays recent items (posts or topics) from your forum.</description>
<version>1.0</version>

Expand Down

0 comments on commit e5364fb

Please sign in to comment.