mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
Merge branch 'master' of https://github.com/humhub/humhub
This commit is contained in:
commit
8893340c2b
@ -51,7 +51,8 @@ HumHub Change Log
|
||||
- Fix: Do not store complete comments with search index (helnokaly)
|
||||
- Fix #2319: Run console application before installation
|
||||
- Fix: Directory Knob statistics on included modules (e.g. Enterprise Edition)
|
||||
|
||||
- Enh: Added widget to display user profile image
|
||||
- Enh: Directory view templates cleanups
|
||||
|
||||
1.2.0-beta.2 (February 24, 2017)
|
||||
--------------------------------
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $groups humhub\modules\user\models\Group[] */
|
||||
|
||||
use yii\helpers\Url;
|
||||
use yii\helpers\Html;
|
||||
|
||||
use humhub\modules\directory\widgets\GroupUsers;
|
||||
?>
|
||||
<div class="panel panel-default groups">
|
||||
|
||||
@ -12,23 +13,9 @@ use yii\helpers\Html;
|
||||
|
||||
<div class="panel-body">
|
||||
<?php foreach ($groups as $group) : ?>
|
||||
<?php $userCount = $group->getGroupUsers()->count(); ?>
|
||||
|
||||
<?php if ($userCount != 0) : ?>
|
||||
<h1><?php echo Html::encode($group->name); ?></h1>
|
||||
<?php foreach ($group->getUsers()->active()->limit(30)->joinWith('profile')->orderBy(['profile.lastname' => SORT_ASC])->all() as $user) : ?>
|
||||
<a id="<?php echo $user->guid; ?>" href="<?php echo $user->getUrl(); ?>">
|
||||
<img data-toggle="tooltip" data-placement="top" title=""
|
||||
data-original-title="<?php echo Html::encode($user->displayName); ?>"
|
||||
src="<?php echo $user->getProfileImage()->getUrl(); ?>" class="img-rounded tt img_margin"
|
||||
height="40"
|
||||
width="40" alt="40x40" data-src="holder.js/40x40" style="width: 40px; height: 40px;"/></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($userCount >= 30) : ?>
|
||||
<?php echo Html::a(Yii::t('DirectoryModule.base', "show all members"), Url::to(['/directory/directory/members', 'keyword' => '', 'groupId' => $group->id])); ?>
|
||||
<?php endif; ?>
|
||||
<hr>
|
||||
<?php endif; ?>
|
||||
<h1><?= Html::encode($group->name); ?></h1>
|
||||
<?= GroupUsers::widget(['group' => $group]); ?>
|
||||
<hr />
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
|
@ -1,116 +1,71 @@
|
||||
<?php
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $keyword string */
|
||||
/* @var $group humhub\modules\user\models\Group */
|
||||
/* @var $users humhub\modules\user\models\User[] */
|
||||
/* @var $pagination yii\data\Pagination */
|
||||
|
||||
use yii\helpers\Url;
|
||||
use yii\helpers\Html;
|
||||
use humhub\modules\friendship\models\Friendship;
|
||||
use humhub\modules\user\widgets\Image;
|
||||
use humhub\modules\directory\widgets\MemberActionsButton;
|
||||
use humhub\modules\directory\widgets\UserTagList;
|
||||
use humhub\modules\directory\widgets\UserGroupList;
|
||||
?>
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<?php if ($group === null) : ?>
|
||||
<?php echo Yii::t('DirectoryModule.base', '<strong>Member</strong> directory'); ?>
|
||||
<?= Yii::t('DirectoryModule.base', '<strong>Member</strong> directory'); ?>
|
||||
<?php else: ?>
|
||||
<?php echo Yii::t('DirectoryModule.base', '<strong>Group</strong> members - {group}', ['{group}' => $group->name]); ?>
|
||||
<?= Yii::t('DirectoryModule.base', '<strong>Group</strong> members - {group}', ['{group}' => Html::encode($group->name)]); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<!-- search form -->
|
||||
<?php echo Html::beginForm(Url::to(['/directory/directory/members']), 'get', array('class' => 'form-search')); ?>
|
||||
<?= Html::beginForm('', 'get', ['class' => 'form-search']); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group form-group-search">
|
||||
<?php echo Html::textInput("keyword", $keyword, array("class" => "form-control form-search", "placeholder" => Yii::t('DirectoryModule.base', 'search for members'))); ?>
|
||||
<?php echo Html::submitButton(Yii::t('DirectoryModule.base', 'Search'), array('class' => 'btn btn-default btn-sm form-button-search')); ?>
|
||||
<?= Html::textInput("keyword", $keyword, ['class' => 'form-control form-search', 'placeholder' => Yii::t('DirectoryModule.base', 'search for members')]); ?>
|
||||
<?= Html::submitButton(Yii::t('DirectoryModule.base', 'Search'), ['class' => 'btn btn-default btn-sm form-button-search']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3"></div>
|
||||
</div>
|
||||
<?php echo Html::endForm(); ?>
|
||||
<?= Html::endForm(); ?>
|
||||
|
||||
<?php if (count($users) == 0): ?>
|
||||
<p><?php echo Yii::t('DirectoryModule.base', 'No members found!'); ?></p>
|
||||
<p><?= Yii::t('DirectoryModule.base', 'No members found!'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<ul class="media-list">
|
||||
<!-- BEGIN: Results -->
|
||||
<?php foreach ($users as $user) : ?>
|
||||
<li>
|
||||
<div class="media">
|
||||
|
||||
<!-- Follow Handling -->
|
||||
<div class="pull-right">
|
||||
<?=
|
||||
\humhub\modules\user\widgets\UserFollowButton::widget([
|
||||
'user' => $user,
|
||||
'followOptions' => ['class' => 'btn btn-primary btn-sm'],
|
||||
'unfollowOptions' => ['class' => 'btn btn-info btn-sm']
|
||||
]);
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (!Yii::$app->user->isGuest && !$user->isCurrentUser() && Yii::$app->getModule('friendship')->getIsEnabled()) {
|
||||
$friendShipState = Friendship::getStateForUser(Yii::$app->user->getIdentity(), $user);
|
||||
if ($friendShipState === Friendship::STATE_NONE) {
|
||||
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t("FriendshipModule.base", "Add Friend"), Url::to(['/friendship/request/add', 'userId' => $user->id]), array('class' => 'btn btn-primary btn-sm', 'data-method' => 'POST'));
|
||||
} elseif ($friendShipState === Friendship::STATE_FRIENDS) {
|
||||
echo Html::a('<span class="glyphicon glyphicon-ok"></span> ' . Yii::t("FriendshipModule.base", "Friends"), $user->getUrl(), ['class' => 'btn btn-info btn-sm']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="pull-right memberActions">
|
||||
<?= MemberActionsButton::widget(['user' => $user]); ?>
|
||||
</div>
|
||||
|
||||
<a href="<?php echo $user->getUrl(); ?>" class="pull-left">
|
||||
<img class="media-object img-rounded"
|
||||
src="<?php echo $user->getProfileImage()->getUrl(); ?>" width="50"
|
||||
height="50" alt="50x50" data-src="holder.js/50x50"
|
||||
style="width: 50px; height: 50px;">
|
||||
</a>
|
||||
|
||||
|
||||
<?= Image::widget(['user' => $user, 'htmlOptions' => ['class' => 'pull-left']]); ?>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a
|
||||
href="<?php echo $user->getUrl(); ?>"><?php echo Html::encode($user->displayName); ?></a>
|
||||
<?php if ($user->hasGroup()) : ?>
|
||||
<small>(<?=
|
||||
implode(', ', array_map(function($g) {
|
||||
return Html::encode($g->name);
|
||||
}, $user->groups));
|
||||
?>)</small>
|
||||
<?php endif; ?>
|
||||
<h4 class="media-heading">
|
||||
<a href="<?= $user->getUrl(); ?>"><?= Html::encode($user->displayName); ?></a>
|
||||
<?= UserGroupList::widget(['user' => $user]); ?>
|
||||
</h4>
|
||||
<h5><?php echo Html::encode($user->profile->title); ?></h5>
|
||||
|
||||
<?php $tag_count = 0; ?>
|
||||
<?php if ($user->hasTags()) : ?>
|
||||
<?php foreach ($user->getTags() as $tag): ?>
|
||||
<?php if ($tag_count <= 5) { ?>
|
||||
<?php echo Html::a(Html::encode($tag), Url::to(['/directory/directory/members', 'keyword' => $tag]), array('class' => 'label label-default')); ?>
|
||||
<?php
|
||||
$tag_count++;
|
||||
}
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<h5><?= Html::encode($user->profile->title); ?></h5>
|
||||
<?= UserTagList::widget(['user' => $user]); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<?php endforeach; ?>
|
||||
<!-- END: Results -->
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="pagination-container">
|
||||
<?php echo \humhub\widgets\LinkPager::widget(['pagination' => $pagination]); ?>
|
||||
<?= \humhub\widgets\LinkPager::widget(['pagination' => $pagination]); ?>
|
||||
</div>
|
||||
|
@ -1,101 +1,75 @@
|
||||
<?php
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $keyword string */
|
||||
/* @var $spaces humhub\modules\space\models\Space[] */
|
||||
/* @var $pagination yii\data\Pagination */
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use humhub\libs\Helpers;
|
||||
use humhub\widgets\LinkPager;
|
||||
use humhub\modules\space\widgets\FollowButton;
|
||||
use humhub\modules\space\widgets\Image;
|
||||
use humhub\modules\directory\widgets\SpaceTagList;
|
||||
?>
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<?php echo Yii::t('DirectoryModule.base', '<strong>Space</strong> directory'); ?>
|
||||
<?= Yii::t('DirectoryModule.base', '<strong>Space</strong> directory'); ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<?php echo Html::beginForm(Url::to(['/directory/directory/spaces']), 'get', array('class' => 'form-search')); ?>
|
||||
<?= Html::beginForm(Url::to(['/directory/directory/spaces']), 'get', ['class' => 'form-search']); ?>
|
||||
<div class="row">
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group form-group-search">
|
||||
<?php echo Html::textInput("keyword", $keyword, array("class" => "form-control form-search", "placeholder" => Yii::t('DirectoryModule.base', 'search for spaces'))); ?>
|
||||
<?php echo Html::submitButton(Yii::t('DirectoryModule.base', 'Search'), array('class' => 'btn btn-default btn-sm form-button-search')); ?>
|
||||
<?= Html::textInput('keyword', $keyword, ['class' => 'form-control form-search', 'placeholder' => Yii::t('DirectoryModule.base', 'search for spaces')]); ?>
|
||||
<?= Html::submitButton(Yii::t('DirectoryModule.base', 'Search'), ['class' => 'btn btn-default btn-sm form-button-search']); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3"></div>
|
||||
</div>
|
||||
<?php echo Html::endForm(); ?>
|
||||
|
||||
<?= Html::endForm(); ?>
|
||||
|
||||
<?php if (count($spaces) == 0): ?>
|
||||
<p><?php echo Yii::t('DirectoryModule.base', 'No spaces found!'); ?></p>
|
||||
<p><?= Yii::t('DirectoryModule.base', 'No spaces found!'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<ul class="media-list">
|
||||
|
||||
<!-- BEGIN: Results -->
|
||||
<?php foreach ($spaces as $space) : ?>
|
||||
<li>
|
||||
<div class="media">
|
||||
|
||||
<!-- Follow Handling -->
|
||||
<div class="pull-right">
|
||||
<?php
|
||||
humhub\modules\space\widgets\FollowButton::widget([
|
||||
'space' => $space,
|
||||
'followOptions' => ['class' => 'btn btn-primary btn-sm'],
|
||||
'unfollowOptions' => ['class' => 'btn btn-info btn-sm']
|
||||
]);
|
||||
<?=
|
||||
FollowButton::widget([
|
||||
'space' => $space,
|
||||
'followOptions' => ['class' => 'btn btn-primary btn-sm'],
|
||||
'unfollowOptions' => ['class' => 'btn btn-info btn-sm']
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php echo \humhub\modules\space\widgets\Image::widget([
|
||||
'space' => $space,
|
||||
'width' => 50,
|
||||
'htmlOptions' => [
|
||||
'class' => 'media-object',
|
||||
],
|
||||
'link' => 'true',
|
||||
'linkOptions' => [
|
||||
'class' => 'pull-left',
|
||||
],
|
||||
]); ?>
|
||||
<?= Image::widget(['space' => $space, 'width' => 50, 'htmlOptions' => ['class' => 'media-object'], 'link' => true, 'linkOptions' => ['class' => 'pull-left']]); ?>
|
||||
|
||||
<?php if ($space->isMember()) { ?>
|
||||
<i class="fa fa-user space-member-sign tt" data-toggle="tooltip" data-placement="top"
|
||||
title=""
|
||||
data-original-title="<?php echo Yii::t('DirectoryModule.base', 'You are a member of this space'); ?>"></i>
|
||||
<?php } ?>
|
||||
<?php if ($space->isMember()): ?>
|
||||
<i class="fa fa-user space-member-sign tt" data-toggle="tooltip" data-placement="top" title=""
|
||||
data-original-title="<?= Yii::t('DirectoryModule.base', 'You are a member of this space'); ?>"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading"><a
|
||||
href="<?php echo $space->getUrl(); ?>"><?php echo Html::encode($space->name); ?></a>
|
||||
</h4>
|
||||
<h5><?php echo Html::encode(humhub\libs\Helpers::truncateText($space->description, 100)); ?></h5>
|
||||
|
||||
<?php $tag_count = 0; ?>
|
||||
<?php if ($space->hasTags()) : ?>
|
||||
<?php foreach ($space->getTags() as $tag): ?>
|
||||
<?php if ($tag_count <= 5) { ?>
|
||||
<?php echo Html::a(Html::encode($tag), ['/directory/directory/spaces', 'keyword' => $tag], array('class' => 'label label-default')); ?>
|
||||
<?php
|
||||
$tag_count++;
|
||||
}
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<h4 class="media-heading"><a href="<?= $space->getUrl(); ?>"><?= Html::encode($space->name); ?></a></h4>
|
||||
<h5><?= Html::encode(Helpers::truncateText($space->description, 100)); ?></h5>
|
||||
<?= SpaceTagList::widget(['space' => $space]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!-- END: Results -->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="pagination-container">
|
||||
<?php echo \humhub\widgets\LinkPager::widget(array('pagination' => $pagination)); ?>
|
||||
<?= LinkPager::widget(['pagination' => $pagination]); ?>
|
||||
</div>
|
||||
|
61
protected/humhub/modules/directory/widgets/GroupUsers.php
Normal file
61
protected/humhub/modules/directory/widgets/GroupUsers.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\libs\Html;
|
||||
use humhub\modules\user\models\Group;
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* GroupUsers shows users of a group
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class GroupUsers extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Group
|
||||
*/
|
||||
public $group;
|
||||
|
||||
/**
|
||||
* @var int maximum number of users to display
|
||||
*/
|
||||
public $maxUsers = 30;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$users = $this->group->getUsers()->active()->limit($this->maxUsers + 1)->joinWith('profile')->orderBy(['profile.lastname' => SORT_ASC])->all();
|
||||
|
||||
|
||||
if (count($users) === 0) {
|
||||
return Html::tag('small', Yii::t('DirectoryModule.base', 'This group has no members yet.'));
|
||||
}
|
||||
|
||||
$showMoreUrl = '';
|
||||
if (count($users) > $this->maxUsers) {
|
||||
array_pop($users);
|
||||
$showMoreUrl = Url::to(['/directory/directory/members', 'keyword' => '', 'groupId' => $this->group->id]);
|
||||
}
|
||||
|
||||
return $this->render('groupUsers', [
|
||||
'group' => $this->group,
|
||||
'users' => $users,
|
||||
'showMoreUrl' => $showMoreUrl
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* MemberActionsButton shows directory options (following or friendship) for listed users
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class MemberActionsButton extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \humhub\modules\user\models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
return $this->render('memberActionsButton', [
|
||||
'user' => $this->user
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
57
protected/humhub/modules/directory/widgets/SpaceTagList.php
Normal file
57
protected/humhub/modules/directory/widgets/SpaceTagList.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use humhub\libs\Html;
|
||||
use yii\helpers\Url;
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* SpaceTagList displays the user tags on the directory page
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class SpaceTagList extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \humhub\modules\space\models\Space
|
||||
*/
|
||||
public $space;
|
||||
|
||||
/**
|
||||
* @var int number of max. displayed tags
|
||||
*/
|
||||
public $maxTags = 5;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$tags = $this->space->getTags();
|
||||
|
||||
$count = count($tags);
|
||||
|
||||
if ($count === 0) {
|
||||
return;
|
||||
} elseif ($count > $this->maxTags) {
|
||||
$tags = array_slice($tags, 0, $this->maxTags);
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($tags as $tag) {
|
||||
$html .= Html::a(Html::encode($tag), Url::to(['/directory/directory/spaces', 'keyword' => $tag]), ['class' => 'label label-default']) . " ";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
54
protected/humhub/modules/directory/widgets/UserGroupList.php
Normal file
54
protected/humhub/modules/directory/widgets/UserGroupList.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use humhub\libs\Html;
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* UserGroupList displays a comma separated list of user groups
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class UserGroupList extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \humhub\modules\user\models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var string Tag name for base HTML tag
|
||||
*/
|
||||
public $tagName = 'small';
|
||||
|
||||
/**
|
||||
* @var array the HTML Options fo the base Tag
|
||||
*/
|
||||
public $htmlOptions = [];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (!$this->user->hasGroup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$groupList = implode(', ', array_map(function($g) {
|
||||
return Html::encode($g->name);
|
||||
}, $this->user->groups));
|
||||
|
||||
return Html::tag($this->tagName, $groupList, $this->htmlOptions);
|
||||
}
|
||||
|
||||
}
|
58
protected/humhub/modules/directory/widgets/UserTagList.php
Normal file
58
protected/humhub/modules/directory/widgets/UserTagList.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use humhub\libs\Html;
|
||||
use yii\helpers\Url;
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* UserTagList displays the user tags on the directory page
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class UserTagList extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \humhub\modules\user\models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var int number of max. displayed tags
|
||||
*/
|
||||
public $maxTags = 5;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$tags = $this->user->getTags();
|
||||
|
||||
$count = count($tags);
|
||||
|
||||
if ($count === 0) {
|
||||
return;
|
||||
} elseif ($count > $this->maxTags) {
|
||||
$tags = array_slice($tags, 0, $this->maxTags);
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($tags as $tag) {
|
||||
$html .= Html::a(Html::encode($tag), Url::to(['/directory/directory/members', 'keyword' => $tag]), ['class' => 'label label-default']) . " ";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $group humhub\modules\user\models\Group */
|
||||
/* @var $users humhub\modules\user\models\User[] */
|
||||
/* @var $showMoreurl string */
|
||||
|
||||
use humhub\libs\Html;
|
||||
use humhub\modules\user\widgets\Image;
|
||||
?>
|
||||
<?php foreach ($users as $user): ?>
|
||||
<?= Image::widget(['user' => $user, 'width' => 40, 'showTooltip' => true]); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (!empty($showMoreUrl)) : ?>
|
||||
<?= Html::a(Yii::t('DirectoryModule.base', "show all members"), $showMoreUrl, ['class' => 'btn btn-sm btn-default']); ?>
|
||||
<?php endif; ?>
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $user humhub\modules\user\models\User */
|
||||
|
||||
use humhub\modules\friendship\models\Friendship;
|
||||
use humhub\modules\user\widgets\UserFollowButton;
|
||||
use humhub\libs\Html;
|
||||
use yii\helpers\Url;
|
||||
?>
|
||||
<?=
|
||||
|
||||
UserFollowButton::widget([
|
||||
'user' => $user,
|
||||
'followOptions' => ['class' => 'btn btn-primary btn-sm'],
|
||||
'unfollowOptions' => ['class' => 'btn btn-info btn-sm']
|
||||
]);
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!Yii::$app->user->isGuest && !$user->isCurrentUser() && Yii::$app->getModule('friendship')->getIsEnabled()) {
|
||||
$friendShipState = Friendship::getStateForUser(Yii::$app->user->getIdentity(), $user);
|
||||
if ($friendShipState === Friendship::STATE_NONE) {
|
||||
echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t("FriendshipModule.base", "Add Friend"), Url::to(['/friendship/request/add', 'userId' => $user->id]), array('class' => 'btn btn-primary btn-sm', 'data-method' => 'POST'));
|
||||
} elseif ($friendShipState === Friendship::STATE_FRIENDS) {
|
||||
echo Html::a('<span class="glyphicon glyphicon-ok"></span> ' . Yii::t("FriendshipModule.base", "Friends"), $user->getUrl(), ['class' => 'btn btn-info btn-sm']);
|
||||
}
|
||||
}
|
||||
?>
|
@ -2,22 +2,18 @@
|
||||
|
||||
use yii\helpers\Url;
|
||||
use yii\helpers\Html;
|
||||
use humhub\widgets\PanelMenu;
|
||||
use humhub\modules\user\widgets\Image;
|
||||
?>
|
||||
<div class="panel panel-default members" id="new-people-panel">
|
||||
<!-- Display panel menu widget -->
|
||||
<?php echo \humhub\widgets\PanelMenu::widget(array('id' => 'new-people-panel')); ?>
|
||||
<?= PanelMenu::widget(['id' => 'new-people-panel']); ?>
|
||||
|
||||
<div class="panel-heading">
|
||||
<?php echo Yii::t('DirectoryModule.base', '<strong>New</strong> people'); ?>
|
||||
<?= Yii::t('DirectoryModule.base', '<strong>New</strong> people'); ?>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<?php foreach ($newUsers->limit(10)->all() as $user) : ?>
|
||||
<a href="<?php echo $user->getUrl(); ?>">
|
||||
<img src="<?php echo $user->getProfileImage()->getUrl(); ?>" class="img-rounded tt img_margin"
|
||||
height="40" width="40" alt="40x40" data-src="holder.js/40x40" style="width: 40px; height: 40px;"
|
||||
data-toggle="tooltip" data-placement="top" title=""
|
||||
data-original-title="<?php echo Html::encode($user->displayName); ?>">
|
||||
</a>
|
||||
<?= Image::widget(['user' => $user, 'width' => 40, 'showTooltip' => true]); ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($showInviteButton || $showMoreButton): ?>
|
||||
@ -25,10 +21,10 @@ use yii\helpers\Html;
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($showInviteButton): ?>
|
||||
<?php echo Html::a('<i class="fa fa-paper-plane" aria-hidden="true"></i> ' . Yii::t('DirectoryModule.base', 'Send invite'), Url::to(['/user/invite']), array('data-target' => '#globalModal')); ?>
|
||||
<?= Html::a('<i class="fa fa-paper-plane" aria-hidden="true"></i> ' . Yii::t('DirectoryModule.base', 'Send invite'), Url::to(['/user/invite']), array('data-target' => '#globalModal')); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($showMoreButton): ?>
|
||||
<?php echo Html::a('<i class="fa fa-list-ul" aria-hidden="true"></i> ' . Yii::t('DirectoryModule.base', 'See all'), Url::to(['/directory/directory/members']), array('classx' => 'btn btn-xl btn-primary', 'class' => 'pull-right')); ?>
|
||||
<?= Html::a('<i class="fa fa-list-ul" aria-hidden="true"></i> ' . Yii::t('DirectoryModule.base', 'See all'), Url::to(['/directory/directory/members']), array('classx' => 'btn btn-xl btn-primary', 'class' => 'pull-right')); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
@ -21,21 +21,52 @@ class Image extends Widget
|
||||
* @var \humhub\modules\space\models\Space
|
||||
*/
|
||||
public $space;
|
||||
|
||||
/**
|
||||
* @var int number of characters used in the acronym
|
||||
*/
|
||||
public $acronymCount = 2;
|
||||
public $width;
|
||||
public $height;
|
||||
|
||||
/**
|
||||
* @var int the width of the image
|
||||
*/
|
||||
public $width = 50;
|
||||
|
||||
/**
|
||||
* @var int the height of the image
|
||||
*/
|
||||
public $height = null;
|
||||
|
||||
/**
|
||||
* @var array html options for the generated tag
|
||||
*/
|
||||
public $htmlOptions = [];
|
||||
|
||||
/**
|
||||
* @var boolean create link to the space
|
||||
*/
|
||||
public $link = false;
|
||||
|
||||
/**
|
||||
* @var array Html Options of the link
|
||||
*/
|
||||
public $linkOptions = [];
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->height === null) {
|
||||
$this->height = $this->width;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (!$this->height) {
|
||||
$this->height = $this->width;
|
||||
}
|
||||
|
||||
if (!isset($this->linkOptions['href'])) {
|
||||
$this->linkOptions['href'] = $this->space->getUrl();
|
||||
|
101
protected/humhub/modules/user/widgets/Image.php
Normal file
101
protected/humhub/modules/user/widgets/Image.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use humhub\libs\Html;
|
||||
use humhub\components\Widget;
|
||||
|
||||
/**
|
||||
* Image shows the user profile image
|
||||
*
|
||||
* @since 1.2
|
||||
* @author Luke
|
||||
*/
|
||||
class Image extends Widget
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \humhub\modules\user\models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @var int the image width in pixcel
|
||||
*/
|
||||
public $width = 50;
|
||||
|
||||
/**
|
||||
* @var int the image height in pixel (optional)
|
||||
*/
|
||||
public $height = null;
|
||||
|
||||
/**
|
||||
* @var boolean add link to user profile
|
||||
*/
|
||||
public $link = true;
|
||||
|
||||
/**
|
||||
* @var array optional html options for the link tag
|
||||
*/
|
||||
public $linkOptions = [];
|
||||
|
||||
/**
|
||||
* @var array optional html options for the base tag
|
||||
*/
|
||||
public $htmlOptions = [];
|
||||
|
||||
/**
|
||||
* @var array optional html options for the image tag
|
||||
*/
|
||||
public $imageOptions = [];
|
||||
|
||||
/**
|
||||
* @var string show tooltip with further information about the user
|
||||
*/
|
||||
public $showTooltip = false;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->height === null) {
|
||||
$this->height = $this->width;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Html::addCssClass($this->imageOptions, 'img-rounded');
|
||||
Html::addCssStyle($this->imageOptions, 'width: ' . $this->width . 'px; height: ' . $this->height . 'px');
|
||||
|
||||
if ($this->showTooltip) {
|
||||
$this->imageOptions['data-toggle'] = 'tooltip';
|
||||
$this->imageOptions['data-placement'] = 'top';
|
||||
$this->imageOptions['data-original-title'] = Html::encode($this->user->displayName);
|
||||
Html::addCssClass($this->imageOptions, 'tt');
|
||||
}
|
||||
|
||||
$html = Html::img($this->user->getProfileImage()->getUrl(), $this->imageOptions);
|
||||
|
||||
if ($this->link) {
|
||||
$html = Html::a($html, $this->user->getUrl(), $this->linkOptions);
|
||||
}
|
||||
|
||||
$html = Html::tag('span', $html, $this->htmlOptions);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user