本文整理汇总了PHP中cebe\gravatar\Gravatar::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP Gravatar::widget方法的具体用法?PHP Gravatar::widget怎么用?PHP Gravatar::widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cebe\gravatar\Gravatar
的用法示例。
在下文中一共展示了Gravatar::widget方法的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: 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');
}
示例4:
<?php
echo Yii::t('writesdown', '{userCount} Members', ['userCount' => $userCount]);
?>
</span>
<button data-widget="collapse" class="btn btn-box-tool"><i class="fa fa-minus"></i></button>
<button data-widget="remove" class="btn btn-box-tool"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body no-padding">
<ul class="users-list clearfix">
<?php
foreach ($users as $user) {
?>
<li>
<?php
echo Gravatar::widget(['email' => $user->email, 'options' => ['alt' => $user->username], 'size' => 128]);
?>
<?php
echo Html::a($user->display_name, $user->url, ['class' => 'users-list-name']);
?>
<?php
echo Html::tag('span', Yii::$app->formatter->asDate($user->created_at), ['class' => 'users-list-date']);
?>
</li>
<?php
}
?>
</ul>
</div>
</div>
</div>
示例5:
echo Yii::t('admin', 'Live edit');
?>
</span>
</div>
<div class="user-menu">
<a href="#"><?php
echo $userIdentity->username;
?>
</a>
<div class="sub-wrapper">
<ul class="submenu">
<li>
<a href="#">
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => $userIdentity->email, 'size' => 64, 'options' => ['alt' => Yii::t('admin', 'Avatar image for {username}', ['username' => $userIdentity->username]), 'class' => 'avatar']]);
?>
<span class="full-name">
<?php
echo $userIdentity->publicIdentity;
?>
(<small class="username"><?php
echo $userIdentity->username;
?>
</small>)
</span>
</a>
</li>
<li>
<a href="<?php
echo Url::to(['/user/default/logout']);
示例6:
<?php
use cebe\gravatar\Gravatar;
use yii\helpers\Url;
/* @var \app\components\View $this */
/* @var \user\models\User $user */
$this->title = $user->username;
$this->params['page'] = 'login';
$formatter = Yii::$app->formatter;
?>
<div class="page-profile">
<div class="vcard">
<div class="profile-avatar">
<?php
echo Gravatar::widget(['email' => $user->email, 'options' => ['alt' => $user->username, 'class' => 'avatar', 'width' => 250, 'height' => 250], 'defaultImage' => 'retro', 'size' => 250]);
?>
</div>
<?php
if (Yii::$app->getUser()->can('updateProfile', ['user' => $user])) {
?>
<?php
if (Yii::$app->getUser()->getIdentity()->getId() == $user->id) {
?>
<a class="btn profile-edit-btn" href="<?php
echo Url::toRoute(['/user/settings/profile']);
?>
"><span class="octicon octicon-pencil"></span> Редактировать профиль</a>
<?php
} else {
?>
<a class="btn profile-edit-btn" href="<?php
示例7:
</div>
<div class="tab-pane vertical-pad" id="photo">
<?php
echo $form->field($model, 'image')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'gif', 'png']]]);
?>
</div> <!-- end of upload photo tab -->
<div class="form-group">
<?php
echo Html::submitButton(Yii::t('frontend', 'Save Settings'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>
</div> <!-- end tab content -->
</div> <!--end left col -->
<div class="col-md-4">
<?php
if ($model->avatar != '') {
echo '<img src="' . Yii::getAlias('@web') . '/uploads/avatar/sqr_' . $model->avatar . '" class="profile-image"/>';
} else {
echo \cebe\gravatar\Gravatar::widget(['email' => common\models\User::find()->where(['id' => Yii::$app->user->getId()])->one()->email, 'options' => ['class' => 'profile-image', 'alt' => common\models\User::find()->where(['id' => Yii::$app->user->getId()])->one()->username], 'size' => 128]);
}
?>
</div> <!--end rt col -->
<?php
ActiveForm::end();
?>
</div>
示例8:
<?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">
示例9: 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]);
示例10:
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']);
示例11:
<li class="user-header">
<?php
if ($userIdentity->userProfile->avatar != '') {
?>
<img class="img-circle" src="<?php
echo $userIdentity->userProfile->getThumbUploadUrl('avatar');
?>
" alt="<?php
echo Yii::t('app', 'Avatar image for {username}', ['username' => $userIdentity->username]);
?>
">
<?php
} else {
?>
<?php
echo \cebe\gravatar\Gravatar::widget(['email' => $userIdentity->email, 'size' => 160, 'options' => ['alt' => Yii::t('app', 'Avatar image for {username}', ['username' => $userIdentity->username]), 'class' => 'img-circle']]);
?>
<?php
}
?>
<p>
<?php
echo $userIdentity->publicIdentity;
?>
- <?php
echo $userIdentity->username;
?>
<small><?php
echo Yii::t('app', 'Joined in {datetime}', ['datetime' => Yii::$app->formatter->asDatetime($userIdentity->created_at)]);
?>
</small>
示例12:
</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']);
?>
示例13: isset
?>
installs<br/>
<span class="label label-warning">This month</span> <?php
echo $model->downloads->monthly;
?>
downloads<br/>
<span class="label label-warning">Today</span> <?php
echo $model->downloads->daily;
?>
downloads<br/>
</p>
<h5>Maintainers</h5>
<?php
foreach ($model->maintainers as $author) {
echo "<p>";
if ($author->email) {
echo Html::a(Gravatar::widget(['email' => $author->email, 'defaultImage' => 'monsterid', 'options' => ['alt' => isset($author->name) ? $author->name : ''], 'size' => 32]), $author->homepage ? $author->homepage : '#');
}
echo " " . ($author->name ? $author->name : '');
echo "</p>";
}
?>
</div>
</div>
<!-- Modal -->
<?php
echo $this->render('_modals', ['name' => $model->name]);
示例14: 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();
?>
示例15: 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>