本文整理汇总了PHP中Avatar::setVars方法的典型用法代码示例。如果您正苦于以下问题:PHP Avatar::setVars方法的具体用法?PHP Avatar::setVars怎么用?PHP Avatar::setVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Avatar
的用法示例。
在下文中一共展示了Avatar::setVars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget_recent_visitors
/**
* 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;
}