当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getAvatar方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:KPEMATOP,项目名称:findspree_old,代码行数:30,代码来源:Html.php

示例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 
开发者ID:kotmonstr,项目名称:kotmonstr,代码行数:31,代码来源:_oneAjaxComment.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);
开发者ID:kotmonstr,项目名称:kotmonstr,代码行数:29,代码来源:views.php


注:本文中的common\models\User::getAvatar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。