本文整理汇总了PHP中common\models\User::getAvatar方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getAvatar方法的具体用法?PHP User::getAvatar怎么用?PHP User::getAvatar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::getAvatar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: avatar
public static function avatar(User $user, $size = 60, $options = [])
{
$size = (int) $size;
unset($options['height'], $options['width']);
static::addCssClass($options, 'ava');
if ($src = $user->getAvatar($size)) {
return static::img($src, $options);
} else {
$cssStyleName = '';
foreach (User::$sizesAvatar as $sizeK => $cssStyleName) {
if ($sizeK >= $size) {
break;
}
}
mb_internal_encoding("UTF-8");
$char1 = mb_substr($user->username, 0, 1);
$char2 = mb_substr($user->username, 1, 1);
$charList = array_merge(String::$charsEng, String::$charsRus);
$posCount = count($charList);
$pos = array_search(mb_strtolower($char1), $charList) ?: 0;
$pos2 = array_search(mb_strtolower($char2), $charList) ?: 0;
$count = count(static::$colorsAvatar);
$colorKey = (int) floor(($pos + $pos2) / ($posCount * 2) * $count);
list($backgroundCol, $textCol) = isset(static::$colorsAvatar[$colorKey]) ? static::$colorsAvatar[$colorKey] : current(self::$colorsAvatar);
static::addCssClass($options, 'fake-avatar');
static::addCssClass($options, 'fake-avatar-' . $cssStyleName);
static::addCssStyle($options, "color:#{$textCol};background:#{$backgroundCol}");
return static::tag('div', $char1 . $char2, $options);
}
}
示例2:
<?php
use common\models\User;
use yii\helpers\StringHelper;
Yii::$app->formatter->locale = 'ru-RU';
?>
<div class="row-fluid" style="opacity: 0">
<div class="container">
<div class="span12 target main-comment pos bg_preview_post">
<div class="span2" style="text-align: center">
<?php
echo User::getAvatar($model->author_id);
?>
<br>
<div class="com-name"><?php
echo $model->author->username;
?>
</div>
</div>
<div class="span8" title="<?php
echo $model->content;
?>
">
<?php
echo StringHelper::truncate($model->content, 1000);
?>
</div>
<div class="span2 time-d">
<?php
示例3: foreach
<center><h5>Коментарии</h5></center>
<?php
if ($coment_model && $coment_model != '') {
?>
<?php
foreach ($coment_model as $model) {
?>
<div class="row target main-comment pos bg_preview_post">
<div class="span2" style="text-align: center">
<?php
echo $model->social == 0 ? User::getAvatar($model->author_id) : User::getAvatarSocial($model->social_avatar);
?>
<br>
<div class="com-name"><?php
echo $model->social == 1 ? $model->social_name : $model->author->username;
?>
</div>
</div>
<div class="span6" title="<?php
echo $model->content;
?>
">
<?php
echo StringHelper::truncate($model->content, 1000);