當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。