/** * Widget Recent Visitors */ public function widget_recent_visitors($h) { $need_cache = false; $label = 'recent_visitors'; // check for a cached version and use it if no recent update: $output = $h->smartCache('html', 'users', 10, '', $label); if ($output) { echo $output; return true; } else { $need_cache = true; } $recent_visitors_settings = $h->getSerializedSettings('recent_visitors'); $limit = $recent_visitors_settings['visitors_num']; $list = $recent_visitors_settings['visitors_list']; $avatars = $recent_visitors_settings['visitors_avatars']; $avatar_size = $recent_visitors_settings['visitors_avatar_size']; $avatar_filter = $recent_visitors_settings['visitors_avatar_filter']; $names = $recent_visitors_settings['visitors_names']; $show_title = $recent_visitors_settings['visitors_widget_title']; $show_get_avatar = $recent_visitors_settings['visitors_widget_get_avatar']; // build the recent visitors: $visitors = $this->getRecentVisitors($h, $limit); if (!$visitors) { return false; } $output = ''; if ($show_title) { $output .= "<h2 class='widget_head widget_recent_visitors_title'>"; $output .= $h->lang["recent_visitors_widget_title"]; $output .= "</h2>\n"; } // if using avatars, set them up here: if ($avatars) { $avatar = new Avatar($h); $avatar->size = $avatar_size; //$avatar->rating = "pg"; // optional - defaults to "g" if not used } $output .= "<div class='widget_body widget_recent_visitors'>"; if ($list) { $output .= "<ul class='recent_visitors_list'>\n"; } foreach ($visitors as $visitor) { $has_avatar = false; if ($avatars) { $avatar->user_id = $visitor->user_id; $avatar->user_email = $visitor->user_email; $avatar->user_name = $visitor->user_username; $avatar->setVars($h); if ($avatar_filter) { $has_avatar = $avatar->testAvatar($h); // testif user has an avatar if (!$has_avatar) { continue; } // skip to the next user } } if ($list) { $output .= "<li class='recent_visitors_item'>"; } if ($avatars) { if ($has_avatar) { $output .= $avatar->linkAvatarImage($h, $has_avatar) . " \n"; // we got the avatar with IMG tags when we tested if the user had an avatar } else { $output .= $avatar->linkAvatar($h) . " \n"; } } if ($names) { $output .= "<a href='" . $h->url(array('user' => $visitor->user_username)) . "'>" . $visitor->user_username . "</a>\n"; } if ($list) { $output .= "</li>"; } else { $output .= " "; } } if ($list) { $output .= "</ul>"; } if ($show_get_avatar) { $output .= "<div class='recent_visitors_get_avatar'>" . $h->lang['recent_visitors_widget_get_avatar'] . "</div>"; } $output .= "</div>"; if ($need_cache) { $h->smartCache('html', 'users', 60, $output, $label); // make or rewrite the cache file } echo $output; }