本文整理汇总了PHP中cebe\gravatar\Gravatar类的典型用法代码示例。如果您正苦于以下问题:PHP Gravatar类的具体用法?PHP Gravatar怎么用?PHP Gravatar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gravatar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Renders the image.
* Based on user settings the avatar can be uploaded image, Gravatar image or default one.
* @return string
*/
public function run()
{
if ($this->author instanceof User) {
$avatar = Html::img(Helper::defaultAvatar(), ['class' => 'podium-avatar img-circle img-responsive center-block', 'alt' => Html::encode($this->author->podiumName)]);
$meta = $this->author->meta;
if ($meta) {
if (!empty($meta->gravatar)) {
$avatar = Gravatar::widget(['email' => $this->author->email, 'defaultImage' => 'identicon', 'rating' => 'r', 'options' => ['alt' => Html::encode($this->author->podiumName), 'class' => 'podium-avatar img-circle img-responsive center-block']]);
} elseif (!empty($meta->avatar)) {
$avatar = Html::img('/avatars/' . $meta->avatar, ['class' => 'podium-avatar img-circle img-responsive center-block', 'alt' => Html::encode($this->author->podiumName)]);
}
}
$name = $this->showName ? $this->author->podiumTag : '';
} else {
$avatar = Html::img(Helper::defaultAvatar(), ['class' => 'podium-avatar img-circle img-responsive center-block', 'alt' => Yii::t('podium/view', 'User deleted')]);
$name = $this->showName ? Helper::deletedUserTag(true) : '';
}
$name = $this->showName ? Html::tag('p', $name, ['class' => 'avatar-name']) : '';
return $avatar . $name;
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
if (strtolower($this->position) == 'header') {
if (!Yii::$app->user->isGuest) {
$user = Yii::$app->user->identity;
$avatar = \cebe\gravatar\Gravatar::widget(['email' => $user->email, 'options' => ['alt' => '', 'class' => 'avatar', 'width' => 24, 'height' => 24], 'defaultImage' => 'retro', 'size' => 24]);
$items[] = ['label' => $avatar . Yii::$app->user->identity->username, 'url' => ['/user/default/view', 'id' => Yii::$app->user->id], 'options' => ['class' => 'navbar-nav-profile']];
}
if (Yii::$app->user->isGuest) {
$items[] = ['label' => 'Регистрация', 'url' => ['/user/identity/registration']];
$items[] = ['label' => 'Вход', 'url' => ['/user/identity/login']];
} else {
$items[] = ['label' => 'Выход', 'url' => ['/user/identity/logout']];
}
return Menu::widget(['items' => $items, 'encodeLabels' => false, 'options' => ['class' => 'navbar-nav']]);
} elseif (strtolower($this->position) == 'sub_header') {
$items[] = ['label' => 'Последние темы', 'url' => ['/topic/default/list']];
if (!Yii::$app->getUser()->getIsGuest()) {
$id = Yii::$app->getUser()->getIdentity()->id;
$notifications = UserMention::countByUser($id);
if ($notifications > 0) {
$items[] = ['label' => 'Уведомления <span class="counter">' . $notifications . '</span>', 'url' => ['/notify/default/view']];
} else {
$items[] = ['label' => 'Уведомления', 'url' => ['/notify/default/view']];
}
}
$items[] = ['label' => 'Пользователи', 'url' => ['/user/default/list']];
if (!Yii::$app->getUser()->getIsGuest()) {
$items[] = ['label' => 'Создать тему', 'url' => ['/topic/default/create']];
}
return Menu::widget(['items' => $items, 'encodeLabels' => false, 'options' => ['class' => 'sub-navbar-nav']]);
} elseif (strtolower($this->position) == 'footer') {
$items = [['label' => 'Правила пользования', 'url' => ['/frontend/default/terms']], ['label' => '•'], ['label' => 'Обратная связь', 'url' => ['/frontend/default/feedback']]];
return Menu::widget(['encodeLabels' => false, 'items' => $items]);
}
return null;
}
示例3:
<?php
use yii\helpers\Html;
?>
<!-- Sidebar user panel -->
<?php
if (!\Yii::$app->user->isGuest) {
?>
<div class="user-panel">
<div class="pull-left image">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => \Yii::$app->user->identity->email, 'options' => ['alt' => \Yii::$app->user->identity->username], 'size' => 64]);
?>
</div>
<div class="pull-left info">
<p><?php
echo \Yii::$app->user->identity->username;
?>
</p>
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
</div>
</div>
<?php
}
?>
<!-- search form -->
<!--<form action="#" method="get" class="sidebar-form">
示例4: foreach
</p>
</div>
<p class="reply">Reply</p>
</article>
<?php
foreach ($post->comments as $childComment) {
?>
<?php
if (!empty($childComment->parentComment) && $childComment->parentComment->id == $comment->id) {
?>
<ul class="children">
<li class="comment">
<article class="media">
<a class="pull-left" href="#">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => $comment->email, 'options' => ['alt' => $comment->name, 'class' => 'media-object'], 'size' => 87]);
?>
</a>
<div class="media-body">
<h5 class="media-heading"><?php
echo $comment->name;
?>
</h5>
<p class="comment-date"><?php
echo date('F j, Y \\a\\t g:i a', strtotime($comment->created_at));
?>
</p>
<p><?php
echo kartik\markdown\Markdown::convert($comment->body);
?>
</p>
示例5: function
<?php
use app\models\User;
use cebe\gravatar\Gravatar;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Users');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['label' => 'Gravatar', 'attribute' => 'email', 'value' => function (User $user) {
return Gravatar::widget(['email' => $user->email, 'size' => 32]);
}, 'format' => 'raw'], 'email:email', 'created_at:datetime', 'updated_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
示例6: displayComment
/**
* @param $comment
* @param int $depth
*
* @throws \Exception
*/
protected function displayComment($comment, $depth = 0)
{
echo Html::beginTag('div', ['id' => 'comment-' . $comment->id, 'class' => $comment->child ? 'parent depth-' . $depth : 'depth-' . $depth]);
?>
<?php
if (Option::get('show_avatars')) {
?>
<div class="media-left avatar">
<?php
echo Gravatar::widget(['email' => $comment->comment_author_email, 'options' => ['alt' => $comment->comment_author, 'class' => 'avatar', 'width' => $this->avatarSize, 'height' => $this->avatarSize], 'defaultImage' => Option::get('avatar_default'), 'rating' => Option::get('avatar_rating'), 'size' => $this->avatarSize]);
?>
</div>
<?php
}
?>
<div class="media-body comment-body">
<p class="meta">
<strong class="author vcard">
<span class="fn">
<?php
echo $comment->comment_author ? $comment->comment_author : \Yii::t('writesdown', 'Anonymous');
?>
</span>
</strong>
-
<time class="date published" datetime="<?php
echo \Yii::$app->formatter->asDatetime($comment->comment_date);
?>
">
<?php
echo \Yii::$app->formatter->asDate($comment->comment_date);
?>
</time>
<?php
if ($depth < $this->maxDepth && $this->enableThreadComments) {
echo Html::a(\Yii::t('writesdown', 'Reply'), '#', ['class' => 'comment-reply-link', 'data-id' => $comment->id]);
}
?>
</p>
<div class="comment-content">
<?php
echo $comment->comment_content;
?>
</div>
</div>
<?php
echo Html::endTag('div');
}
示例7: elseif
?>
</strong>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
<div class="col-sm-3">
<?php
if (!empty($model->meta->gravatar)) {
?>
<?php
echo Gravatar::widget(['email' => PodiumModule::getInstance()->userComponent == PodiumModule::USER_OWN ? $model->email : $model->getEmail(), 'defaultImage' => 'identicon', 'rating' => 'r', 'options' => ['alt' => Yii::t('podium/view', 'Your Gravatar image'), 'class' => 'img-circle img-responsive']]);
} elseif (!empty($model->meta->avatar)) {
?>
<img class="img-circle img-responsive" src="/avatars/<?php
echo $model->meta->avatar;
?>
" alt="<?php
echo Yii::t('podium/view', 'Your avatar');
?>
">
<?php
} else {
?>
<img class="img-circle img-responsive" src="<?php
echo Helper::defaultAvatar();
?>
示例8: buildImgTag
/**
* @inheritdoc
*/
protected function buildImgTag()
{
return Gravatar::widget($this->gravatarOptions);
}
示例9:
</li>
<li class="divider"></li>
<li>
<a class="text-center" href="#">
<strong>See All Alerts</strong>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
<!-- /.dropdown-alerts -->
</li>
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<?php
echo Gravatar::widget(['email' => Yii::$app->user->identity->email, 'size' => 16]);
?>
<i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li>
<p class="navbar-text">
<?php
echo Yii::$app->user->identity->email;
?>
</p>
</li>
<li class="divider"></li>
<li><?php
echo Html::a('<i class="fa fa-user fa-fw"></i> ' . Yii::t('app', 'User Profile'), ['/profile/index']);
?>
示例10: elseif
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row">
<div class="col-sm-3">
<?php
echo $this->render('/elements/profile/_navbar', ['active' => 'profile']);
?>
</div>
<div class="col-sm-9">
<div class="panel panel-default">
<div class="panel-body">
<?php
if (!empty($model->meta->gravatar)) {
?>
<?php
echo Gravatar::widget(['email' => $model->email, 'defaultImage' => 'identicon', 'rating' => 'r', 'options' => ['alt' => Html::encode($model->podiumName), 'class' => 'podium-avatar img-circle img-responsive pull-right']]);
} elseif (!empty($model->meta->avatar)) {
?>
<img class="podium-avatar img-circle img-responsive pull-right" src="/avatars/<?php
echo $model->meta->avatar;
?>
" alt="<?php
echo Html::encode($model->podiumName);
?>
">
<?php
} else {
?>
<img class="podium-avatar img-circle img-responsive pull-right" src="<?php
echo Helper::defaultAvatar();
?>
示例11:
<!-- Sidebar user panel -->
<?php
if (!\Yii::$app->user->isGuest) {
?>
<div class="user-panel">
<div class="pull-left image">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => \Yii::$app->user->identity->profile->gravatar_email === null ? \Yii::$app->user->identity->email : \Yii::$app->user->identity->profile->gravatar_email, 'options' => ['alt' => \Yii::$app->user->identity->username], 'size' => 64]);
?>
</div>
<div class="pull-left info">
<p><?php
echo \Yii::$app->user->identity->username;
?>
</p>
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
</div>
</div>
<?php
}
?>
<!-- search form -->
<!--<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search..."/>
<span class="input-group-btn">
<button type='submit' name='seach' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i></button>
示例12:
">
<time is="time-ago" datetime="<?php
echo Yii::$app->formatter->asDatetime($topic->first_post_created_at, 'php:c');
?>
" title="<?php
echo Yii::$app->formatter->asDatetime($topic->first_post_created_at, 'long');
?>
"><?php
echo $dateTimeAgo->get($topic->first_post_created_at);
?>
</time>
</a>
</div>
<div class="question-author-avatar">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => $topic->firstPostUser->email, 'options' => ['alt' => $topic->firstPostUser->username, 'class' => 'avatar', 'width' => 32, 'height' => 32], 'defaultImage' => 'retro', 'size' => 32]);
?>
</div>
<div class="question-author-info">
<a href="<?php
echo Url::toRoute(['/user/default/view', 'id' => $topic->first_post_user_id]);
?>
"><?php
echo $formatter->asText($topic->first_post_username);
?>
</a>
</div>
</div>
</div>
</div>
<?php
示例13: foreach
<div class="component-comments lang-en" id="comments">
<?php
if (!empty($comments)) {
?>
<ol>
<?php
foreach ($comments as $comment) {
?>
<li class="row">
<div class="col-xs-1 author" id="c<?php
echo $comment->id;
?>
">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => $comment->user->email, 'options' => ['alt' => $comment->user->username], 'size' => 32]);
?>
<?php
echo Html::encode($comment->user->username);
?>
</div>
<div class="col-xs-8 text">
<?php
echo \yii\helpers\Markdown::process($comment->text);
?>
</div>
<div class="col-xs-3">
<a href="#c<?php
echo $comment->id;
?>
">#<?php
示例14: implode
</h3>
<p>
<?php
echo '<span class="label label-default">' . implode("</span><br/><span class='label label-default'>", $version->keywords) . '</span><br/>';
?>
</p>
<?php
// TODO: WE CANNOT REMOVE isset(), fires error if not defined.
if (isset($model->authors)) {
?>
<h5>Maintainers</h5>
<?php
foreach ($model->authors as $author) {
echo "<p>";
if (isset($author->email)) {
echo Html::a(Gravatar::widget(['email' => $author->email, 'options' => ['alt' => isset($author->name) ? $author->name : ''], 'size' => 32]), isset($author->homepage) ? $author->homepage : '#');
}
echo " " . (isset($author->name) ? $author->name : '');
echo "</p>";
}
?>
<?php
}
?>
</div>
</div>
<!-- Modals -->
<?php
echo $this->render('_modals', ['name' => $model->name]);
示例15:
echo Html::beginTag('li', ['class' => $answer['is_answer'] ? 'out' : 'in', 'id' => 'answer-' . $answer['answer_id']]);
?>
<?php
if ($answer['author'] == 'anonym') {
?>
<?php
$answer['email'] = $model->anonym_email;
?>
<?php
}
?>
<?php
if (isset($answer['email']) && filter_var($answer['email'], FILTER_VALIDATE_EMAIL)) {
?>
<?php
echo Gravatar::widget(['email' => $answer['email'], 'defaultImage' => 'identicon', 'options' => ['alt' => $answer['author'], 'class' => 'avatar'], 'size' => 45]);
?>
<?php
}
?>
<div class="message">
<span class="arrow"></span>
<div class="info">
<?php
echo Html::a($answer['author'], ['@client/view', 'id' => $answer['author_id']], ['class' => 'name']);
?>
<?php
echo Html::tag('span', Yii::$app->formatter->asDatetime($answer['create_time']), ['class' => 'datetime']);